71

Possible Duplicate:
Verbose name for admin model Class in django

I had a model with a class like:

class Anh_chi_tiet(models.Model):
    du_an       = models.ForeignKey(Du_an)
    title       = models.CharField(max_length=120)
    url         = models.ImageField(upload_to='images')
    url_detail  = models.ImageField(upload_to='images')

When I go to admin interface, my Anh_chi_tiet class has a label: Anh_chi_tiets (added s suffix) But I want to change my class label to "My image"

How can I do that?

Community
  • 1
  • 1
Son Tran
  • 1,498
  • 4
  • 18
  • 32
  • **verbose_name** is sufficient and don't use **verbose_name_plural**. – hygull Jul 26 '17 at 11:27
  • 1
    It is required if you want **Country** and **Countries** as by default django adds **s** at the end of value of **verbose_name**. So if you will not use **verbose_name_plural** then you will see displayed model name as **Countrys**. – hygull Dec 22 '17 at 15:05
  • If you want to change the name in plural you can use `verbose_name_plural = "stories"` so you don't get `storys` https://docs.djangoproject.com/en/3.0/ref/models/options/#verbose-name-plural – csandreas1 Apr 05 '20 at 10:48

1 Answers1

220

Via inner Meta class, as documented:

class Anh_chi_tiet(models.Model):
    # ... fields ...

    class Meta:
        verbose_name = 'My image'
        verbose_name_plural = 'My images'
Mauro Baraldi
  • 6,346
  • 2
  • 32
  • 43
Cat Plus Plus
  • 125,936
  • 27
  • 200
  • 224
  • 35
    And if you only want to change this in the admin, not everywhere it's used? – Olivier Pons Jan 28 '17 at 22:11
  • 1
    No answer on how to do this in the admin... – polarise Mar 03 '18 at 15:40
  • 2
    You should add the class Meta on the model not on the model admin! – polarise Mar 03 '18 at 15:45
  • 3
    Unfortunatelly changing only the name in the admin won't happens since it defined as `'name': capfirst(model._meta.verbose_name_plural),` (Django 3.1) – Jurrian Oct 02 '20 at 08:29
  • 1
    If you only want to change this in the admin you can use a [proxy model](https://docs.djangoproject.com/en/dev/topics/db/models/#proxy-models). See [this answer in the duplicate question](https://stackoverflow.com/a/65434272/5286674). – kjpc-tech Oct 05 '21 at 17:32