222

How do I change some models name from "Categorys" to "Categories" on admin site in the new dev django version? In the old version (whithout admin sites and admin models) you could just do this; http://www.the-dig.com/blog/post/customize-plural-name-django-admin/

However - now setting verbose_name_plural inside my modeladmin based class does nothing. Anyone encouter the same issue?

Andriy Drozdyuk
  • 58,435
  • 50
  • 171
  • 272
  • It works for me in Django 1.1.1... Are you sure you're putting it inside the Meta nested class? – rescdsk Apr 06 '10 at 19:53
  • yah, I just thought that new versions got rid of the inner Meta class inside the models. Apparently not - they just made things more complicated with Admin classes... – Andriy Drozdyuk Apr 07 '10 at 01:41

2 Answers2

398

Well well, it seems like the Meta class approach still works. So placing a meta class inside your model will still do the trick:

class Category(models.Model):
    class Meta:
        verbose_name_plural = "categories"

Note that we use the lower case here, as django is smart enough to capitalize it when we need it.

I find setting this option in model-class weird as opposed to the admin.py file. Here is the location in the dev docs where it is described:
http://docs.djangoproject.com/en/dev/ref/models/options/#verbose-name-plural

Chase Finch
  • 5,161
  • 1
  • 21
  • 20
Andriy Drozdyuk
  • 58,435
  • 50
  • 171
  • 272
  • 32
    The idea of setting this in the model class (rather than admin.py) boils down to [DRY](http://en.wikipedia.org/wiki/Don%27t_repeat_yourself) - just because the admin is the only thing out-of-the-box that uses this information about your model doesn't mean it will always be. Hopefully if you need the plural name of a model somewhere in your own code you'll use this property instead of re-inventing the wheel. – cibyr Mar 10 '14 at 03:33
45

for that you need to add meta classes for models

class Category(models.Model):
    --- model field here ---
    class Meta: 
        verbose_name = "Category"
        verbose_name_plural = "Categories"

Bonus for your models admin in apps.py

class CategoryConfig(AppConfig):
    name = "Category"
    verbose_name = "Categories"
Saurabh Chandra Patel
  • 12,712
  • 6
  • 88
  • 78
  • 3
    According to the default models in django-admin dashboard, the names should start with lower case. – muel Jan 01 '22 at 19:13