23

I am really very much irritated by the extra "s" added after my class name in django admin eg class 'About' in my model.py becomes 'Abouts' in admin section. And i want it not to add extra 's'. Here is my model.py file-

class About(models.Model):
        about_desc = models.TextField(max_length=5000)

        def __unicode__(self):              # __str__ on Python 3
                return str(self.about_desc)

Please anybody suggest me how django can solve my problem.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Rahul Rathi
  • 249
  • 1
  • 3
  • 6
  • 2
    possible duplicate of [Django fix Admin plural](http://stackoverflow.com/questions/2587707/django-fix-admin-plural) – jonrsharpe Aug 17 '15 at 10:16
  • 1
    Although your question is answered below, this information is readily available in the django tutorial. Don't get irritated until you do a little study. – joel goldstick Aug 17 '15 at 12:05

3 Answers3

45

You can add another class called Meta in your model to specify plural display name. For example, if the model's name is Category, the admin displays Categorys, but by adding the Meta class, we can change it to Categories.

I have changed your code to fix the issue:

class About(models.Model):

    about_desc = models.TextField(max_length=5000)

    def __unicode__(self):              # __str__ on Python 3
        return str(self.about_desc)

    class Meta:
        verbose_name_plural = "about"

For more Meta options, refer to https://docs.djangoproject.com/en/1.8/ref/models/options/

Abhyudit Jain
  • 3,640
  • 2
  • 24
  • 32
8

Take a look at the Model Meta in the django documentation.

Within a Model you can add class Meta this allows additional options for your model which handles things like singular and plural naming.

This can be used in the following way (in english we do not have sheeps) so verbose_name_plural can be used to override djangos attempt at pluralising words:

class Sheep(model.Model):
    class Meta:
        verbose_name_plural = 'Sheep'
Matt Seymour
  • 8,880
  • 7
  • 60
  • 101
3

inside model.py or inside your customized model file add class meta within a Model Class. If not mentioned then a extra 's' will be added at the end of Model Class Name which will be visible in Django Admin Page.

class TestRoles(model.Model): 
   class Meta: verbose_name_plural = 'TestRoles'
dhanya a
  • 31
  • 1