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")
# "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
3条答案
按热度按时间w9apscun1#
查看
Meta
选项verbose_name
和verbose_name_plural
,这两个选项都是可翻译的。rhfm7lfc2#
您应该在所有模型的 meta中使用ugettext_lazy实用程序
2vuwiymt3#
您应该使用gettext_lazy()并将其设置为verbose_name和verbose_name_plural来翻译Django Admin中的模型标签,如下所示。* 你可以看到我的答案,解释如何在Django中翻译: