我有这两位模特管理员:
class SingleImageInline(generic.GenericTabularInline):
model = Image
extra = 1
max_num = 1
can_delete = False
class SponsorAdmin(admin.ModelAdmin):
fieldsets = [
('Basic Info', {
'fields': ['name']
}),
]
list_display = ['name']
search_fields = ['name']
inlines = [SingleImageInline, ]
Sponsor
有一个名为Image
的{{1}}字段。具有logo
表单的管理表单在其标题中显示SingleImageInline
,是否可以将其更改为Images
,可能是这样的?
Logo
答案 0 :(得分:1)
当然可以
class SingleImageInline(generic.GenericTabularInline):
model = Image
extra = 1
max_num = 1
can_delete = False
verbose_name = "Logo"
verbose_name_plural = "Logos"
答案 1 :(得分:0)
你可以给SingleImageInline
提供一个verbose_name:
class SingleImageInline(generic.GenericTabularInline):
model = Image
extra = 1
max_num = 1
can_delete = False
verbose_name = "logo"
verbose_name_plural = "logos"
修改
子类SingleImageInline
,然后放在verbose_name
class SingleImageInline(generic.GenericTabularInline):
model = Image
extra = 1
max_num = 1
can_delete = False
class SingleImageInlineOtherName(SingleimageInline):
verbose_name = "logo"
verbose_name_plural = "logos" # bit redundant as Django automatically adds 's' to plural names, but it's just for the purpose
class SponsorAdmin(admin.ModelAdmin):
fieldsets = [
('Basic Info', {
'fields': ['name']
}),
]
list_display = ['name']
search_fields = ['name']
inlines = [SingleImageInlineOtherName, ] # use the subclass here