50

I could translate Django Admin except a model label because I don't know how to translate a model label in Django Admin.

So, how can I translate a model label in Django Admin?

4 Answers 4

73

Look at the Meta options verbose_name and verbose_name_plural, both of which are translatable.

2
  • 8
    but this will only change the name in home page,but when u click on the link(class) the upper header will display the class name which u mention before. verbose_name will only change the title in home page
    – ha22109
    Mar 19, 2010 at 13:31
  • 1
    In Django 1.11 this is indeed the correct answer. The verbose_name appears on the admin home page and on every sub-page. Aug 16, 2017 at 20:13
21

You should use the ugettext_lazy util in the Meta of all your models

from django.db import models
from django.utils.translation import ugettext_lazy as _

class Book(models.Model):
    ...

    class Meta:
        verbose_name = _("My Book")
        verbose_name_plural = _("My Books")
1
  • 3
    Thanks for the answer, this helped me a lot. Aug 1, 2018 at 3:30
1

You should use gettext_lazy() and set it to verbose_name and verbose_name_plural to translate a model label in Django Admin as shown below. *You can see my answer explaining how to translate in Django in detail:

# "models.py"

from django.db import models
from django.utils.translation import gettext_lazy as _

class Person(models.Model):
    ...

    class Meta:
        verbose_name = _("person") # Here
        verbose_name_plural = _("persons") # Here
0

also you can override admin.ModelAdmin to customize model name in admin only, without changing Model meta

def __init__(self, model: type, admin_site: AdminSite) -> None:
        super().__init__(model, admin_site)
        self.opts.verbose_name = 'your custom model name'
        self.opts.verbose_name_plural = 'your custom title plural'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.