Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Model name visible in Admin section

I am using Python 3.10.0 and Django 3.2.9

I created a new app in my django project, and then created a model called Posts. Everything works as intended except for how it’s name is being displayed in the admin section of the website. It says "Postss" (double s in the end).
If I change the model name to "Post" or just one letter "P" for instance, django automatically adds "s" to the end of it’s name, so it is being displayed as "Posts" or "Ps" then.

Other words, whatever the model name is, django automatically adds "s" in the end of it’s name in the admin pannel of the website.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Is it possible to tell django I don’t want that "s" to be added? How?

screenshot of code and admin pannel

Thanks a mil, guys.

>Solution :

Normally models have singular names, so Post, not Posts. You thus might want to consider renaming your model.

If you still want to use Posts as model name, you can specify the verbose name of the model, and the plural verbose name with the verbose_name [Django-doc] and the verbose_name_plural model options [Django-doc] respectively:

class Posts(models.Model):
    # …
    
    class Meta:
        verbose_name = 'post'
        verbose_name_plural = 'posts'

But as said before, if you rename your model Post, Django will convert the PerlCase to a name with spaces and as plural append the name with an s.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading