Lex Borodai
Lex Borodai

Reputation: 25

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.

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.

Upvotes: 1

Views: 123

Answers (1)

willeM_ Van Onsem
willeM_ Van Onsem

Reputation: 477794

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.

Upvotes: 1

Related Questions