I have two models (Country and State) and I've made only one ModelAdmin for Country with an TabularInline for State.
我有两个模型(国家和州),我只有一个ModelAdmin for Country,有一个TabularInline for State。
class StateInline(admin.TabularInline):
model = State
class CountryAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['name']}),
]
inlines = [StateInline]
admin.site.register(Country, CountryAdmin)
How can I override the verbose_name
Meta property of Country model? I want to rename the form in menu to "Countries / States", instead of only "Countries"?
如何覆盖Country模型的verbose_name Meta属性?我想将菜单中的表单重命名为“Countries / States”,而不仅仅是“States”?
1 个解决方案
#1
10
using Meta
in your model:
在你的模型中:
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")
#1
10
using Meta
in your model:
在你的模型中:
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")