Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » Model named FOOD_DES shows as "foo d_des" in admin [RSS Feed]

#1 June 11, 2010 18:06:15

c.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Model named FOOD_DES shows as "foo d_des" in admin


Hello all,

I have a model named FOOD_DES (the name if from an existing schema
that I'm trying to mirror). When I view it in the admin it's name is
shown as "foo d_des", notice the space.

Any thoughts on why/where the space is added and how I can get rid of
it?

I'm wondering if this something to do with FOO being a computer
programming placeholder name?

Toodle-loooooooooo............
creecode

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 June 11, 2010 19:22:35

Dan H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Model named FOOD_DES shows as "foo d_des" in admin


I'm not sure why you are seeing the space in the admin, but here's a
bit of info regarding changing what is displayed:

You can change a meta option on your model to set what the name will
be displayed as in the admin like so:

class MyModel(models.Model):
field = models.CharField(max_length=100)
class Meta:
verbose_name = "Product" # Your name here
verbose_name_plural = "Products" # Your pluralized name here


Also, if you do not want to name your model as the same name as the
legacy table, you can specify which database table the models uses
with the "db_table" meta option. Please refer to the docs at:http://docs.djangoproject.com/en/1.2/ref/models/options/#model-meta-optionsfor more information.

Cheers,

Dan Harris
dih0...@gmail.com

On Jun 11, 1:06 pm, creecode <creec...@gmail.com> wrote:
> Hello all,
>
> I have a model named FOOD_DES (the name if from an existing schema
> that I'm trying to mirror).  When I view it in the admin it's name is
> shown as "foo d_des", notice the space.
>
> Any thoughts on why/where the space is added and how I can get rid of
> it?
>
> I'm wondering if this something to do with FOO being a computer
> programming placeholder name?
>
> Toodle-loooooooooo............
> creecode

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 June 11, 2010 19:38:24

c.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Model named FOOD_DES shows as "foo d_des" in admin


Hello Dan,

Thanks for the info. verbose_name does take care of the display
problem and I may end up using that option for a more user friendly
experience.

@ALL: I would like to understand where the space is being added. I
have looked around a bit in the source for Django but I haven't seen
anything that pops out. Perhaps this is happening in Python?
Pointers appreciated.

On Jun 11, 11:22 am, Dan Harris <dih0...@gmail.com> wrote:

> You can change a meta option...

Toodle-loooooooooo............
creecode

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#4 June 11, 2010 19:48:21

Dan H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Model named FOOD_DES shows as "foo d_des" in admin


If verbose_name isn't provided the docs say that "Django will use a
munged version of the class name: CamelCase becomes camel case." This
might explain your problem, it looks at FOOD_DES and assumes that the
first F and first O are camel cased words and splits them into two
words, hence the space.

See:http://docs.djangoproject.com/en/1.2/ref/models/options/#verbose-namefor more details.

Cheers,

Dan Harris
dih0...@gmail.com

On Jun 11, 2:38 pm, creecode <creec...@gmail.com> wrote:
> Hello Dan,
>
> Thanks for the info.  verbose_name does take care of the display
> problem and I may end up using that option for a more user friendly
> experience.
>
> @ALL: I would like to understand where the space is being added.  I
> have looked around a bit in the source for Django but I haven't seen
> anything that pops out.  Perhaps this is happening in Python?
> Pointers appreciated.
>
> On Jun 11, 11:22 am, Dan Harris <dih0...@gmail.com> wrote:
>
> > You can change a meta option...
>
> Toodle-loooooooooo............
> creecode

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#5 June 11, 2010 21:12:50

c.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Model named FOOD_DES shows as "foo d_des" in admin


Hello Dan,

On Jun 11, 11:48 am, Dan Harris <dih0...@gmail.com> wrote:

> If verbose_name isn't provided the docs say that "Django will use a
> munged version of the class name: CamelCase becomes camel case."

Thanks again for the info.

> This
> might explain your problem, it looks at FOOD_DES and assumes that the
> first F and first O are camel cased words and splits them into two
> words, hence the space.

This code <http://code.djangoproject.com/browser/django/trunk/django/db/models/options.py> could be the source of where the space is coming from. I'm just
about to run some tests...

Toodle-loooooooooo............
creecode

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#6 June 11, 2010 21:55:07

c.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Model named FOOD_DES shows as "foo d_des" in admin


Hello all,

The line <http://code.djangoproject.com/browser/django/trunk/django/db/models/options.py#L15> in the trunk at this moment is where the action is happening. We
get "foo d_des" because the "_D" in the model name is matched in the
regular expression pattern and the substitution occurs.

My curiosity is satisfied. Thanks!

On Jun 11, 1:12 pm, creecode <creec...@gmail.com> wrote:

> I'm just about to run some tests...

Toodle-loooooooooooo.......
creecode

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » Model named FOOD_DES shows as "foo d_des" in admin [RSS Feed]

Board footer

Moderator control

Enjoy the 20th of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support