我有两个模型(国家和州),我只为国家制作了一个带有TabularInline的ModelAdmin。
class StateInline(admin.TabularInline):
model = State
class CountryAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['name']}),
]
inlines = [StateInline]
admin.site.register(Country, CountryAdmin)
如何覆盖Country模型的verbose_name
Meta属性?我想将菜单中的表单重命名为“Countries / States”,而不仅仅是“Countries”?
答案 0 :(得分:11)
使用Meta
在您的模型中:
from django.utils.tranlation import gettext_lazy as _
class Country(models.Model):
# your fields
class Meta:
verbose_name = _("Country / State")
verbose_name_plural = _("Countries / States")