django:在admin中更改模型的标题

时间:2022-09-11 18:22:19

Django (1.4) by default adds the letter 's' to the model names in the admin site. For example, I have a model class nemed History. When looking in the admin site I found django named it Historys.

Django(1.4)默认情况下会将字母s添加到管理站点的模型名中。例如,我有一个模型类的死敌历史。当我在管理网站查看时,我发现django将它命名为history。

How could I remove this letter and keep the model name as it is ?

我怎么能去掉这封信并保留模型名呢?

2 个解决方案

#1


2  

from django.utils.translation import ugettext_lazy as _

class ModelName(models.Model):
    .................

    class Meta:
        verbose_name_plural = _("History")

#2


0  

Define your own verbose_name_plural in model's Meta class.

在model的Meta类中定义自己的verbose_name_。

https://docs.djangoproject.com/en/dev/ref/models/options/#verbose-name-plural

https://docs.djangoproject.com/en/dev/ref/models/options/ verbose-name-plural

#1


2  

from django.utils.translation import ugettext_lazy as _

class ModelName(models.Model):
    .................

    class Meta:
        verbose_name_plural = _("History")

#2


0  

Define your own verbose_name_plural in model's Meta class.

在model的Meta类中定义自己的verbose_name_。

https://docs.djangoproject.com/en/dev/ref/models/options/#verbose-name-plural

https://docs.djangoproject.com/en/dev/ref/models/options/ verbose-name-plural