def __unicode__(self)
return 'Name you'd like without the s'--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
> def __unicode__(self)
> return 'Name you'd like without the s'
> for each model and this will be used instead.
That's obviously not what he's after.
> On 10 Sep 2011, at 14:40, Gillwill wrote:
> >Apparently the Django default is to append the letter "s" to the end
> > of the model name for each listed under a given application on the
> > Site Administration page. (It does this in the tutorial sample site
> > as
> > well - e.g. naming "poll" "polls", etc...)
> >
> > Is there any way to get rid of that?
First, why is that a problem? If you're using localized model names and
that's where that doesn't fit - you shouldn't, really. You should use
english names for the models and use the i18n infrastructure [1] to
translate the names properly.
Either way [2] and [3] is what you need.
[1] https://docs.djangoproject.com/en/1.3/howto/i18n/
[2]
https://docs.djangoproject.com/en/1.3/ref/models/options/#verbose-name
[3]
https://docs.djangoproject.com/en/1.3/ref/models/options/#verbose-name-plural
Cheers,
--
Michał (Saviq) Sawicz <mic...@sawicz.net>
It was only a problem� insofar as I didn't like the way such a listing looked, particulalrly when I have several models that already, originally,�have an "s" at the end of their name like "Movies", "Books", etc... which would then be listed as "Moviess", "Bookss"...� and removing the "s"�from their class names in models.py�would require many code changes elsewhere in the app.�
Anyway, thanks to all for the solution:
ďż˝
The verbose_name & verbose_name_plural did the trick.
ďż˝-Gil
It's conventional to name model in the singular by default, such as Movie and Book. You have a 'Movie' model, not a 'Movies' model. It also makes the default in the admin make perfect sense. If you have something that does end in is or the plural doesn't end in S (ox/oxen) then use verbose_name_plural.
If you think about it, a "Movies" doesn't have a "title" and "year_released" and a "rating" -- a "Movie" does.
I'm a newbie to object-oriented programming too, so I suppose my mindset is still in procedural, SQL and "recordset" modes, and otherwise: my old ways :-) Thanks for that additional info. Good Points.
AFAICT, most SQL database design texts advice on using singular nouns
for table names. ORMs inherited that practice.
of course, as a newbie, I also made the mistake of using plural names
very often, until I found that advice; and I can say that it really
sounds better after a while.
--
Javier
Casey