Reputation: 15665
I created a project and within the project an app call myusers. I then created a model with the class name AllUsers. I then populated the model with data from faker.
When I go to 127.0.0.1/admin under authorization I have groups and users. Under myusers I have ‘All userss’ which is a link to http://127.0.0.1:8000/admin/myusers/allusers/
so, I’m just wondering if this is a minor bug. Shouldn’t it say ‘AllUsers’ and not ‘All userss’? Or did I corrupt something along the way?
Upvotes: 2
Views: 100
Reputation: 1086
You should not create a model that represents a set of entities. A model should represent a single entity. Since a model should only represent a single entity, Django adds an "s" to the end in the admin to pluralize it (i.e, a model named "Car" will be "Cars" in the admin).
Of course you can change the verbose_plural_name
(https://docs.djangoproject.com/en/3.1/ref/models/options/#verbose-name-plural), but the best way forward is to not continue using this technique to represent all users at all.
To represent all users you should be using a QuerySet.
Upvotes: 2
Reputation: 476659
No, a model normally has a singular name, so AllUser
, not .AllUsers
Django will, based on the name add a suffix …s
for the plural. Indeed, for a model you can check the verbose name with:
>>> from django.contrib.auth.models import User
>>> User.Meta.verbose_name_plural
'users'
For your model you can specify the singluar and plural name yourself with:
class AllUsers(models.Model):
# …
class Meta:
verbose_name = 'all user'
verbose_name_plural = 'all users'
But nevertheless, it is better to give the class a singular name. Especially since other parts, like the default for related_name=…
[Django-doc] is modelname_set
, so for a ForeignKey
of your AllUser
model, that would look like allusers_set
, which does not look very pleasant.
Upvotes: 6