Change model class name in Django admin interface

53,828

Via inner Meta class, as documented:

class Anh_chi_tiet(models.Model):
    # ... fields ...
    class Meta:
        verbose_name = 'My image'
        verbose_name_plural = 'My images'
Share:
53,828
Son Tran
Author by

Son Tran

Love Erlang/Elixir and Software Architecture.

Updated on July 05, 2022

Comments

  • Son Tran
    Son Tran 7 months

    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?

  • Olivier Pons
    Olivier Pons almost 6 years
    And if you only want to change this in the admin, not everywhere it's used?
  • polarise
    polarise almost 5 years
    No answer on how to do this in the admin...
  • polarise
    polarise almost 5 years
    You should add the class Meta on the model not on the model admin!
  • Jurrian over 2 years
    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)
  • kjpc-tech
    kjpc-tech over 1 year
    If you only want to change this in the admin you can use a proxy model. See this answer in the duplicate question.