0

我有这两个模型管理员:

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名为logo. 具有表单的管理表单SingleImageInlineImages显示在其标题中,有没有办法可以将其更改为Logo,可能是这样的?

inlines = [(`Logo`, SingleImageInline), ]
4

2 回答 2

1

你当然可以

class SingleImageInline(generic.GenericTabularInline):
   model = Image
   extra = 1
   max_num = 1
   can_delete = False
   verbose_name = "Logo"
   verbose_name_plural = "Logos"
于 2013-04-17T09:26:29.910 回答
0

你可以给一个 verbose_name SingleImageInline

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
于 2013-04-17T09:28:06.330 回答