49

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?

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
luc
  • 41,928
  • 25
  • 127
  • 172

3 Answers3

73

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

Simon
  • 143
  • 10
Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • 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 '10 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. – Patrick Keenan Aug 16 '17 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")
Dos
  • 2,250
  • 1
  • 29
  • 39
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
Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129