[Answer]-Django: is there a way to specify title for inlines

0๐Ÿ‘

โœ…

You could give a verbose_name to SingleImageInline:

class SingleImageInline(generic.GenericTabularInline):
  model = Image
  extra = 1
  max_num = 1
  can_delete = False
  verbose_name = "logo"
  verbose_name_plural = "logos"

EDIT

subclass SingleImageInline, then put there the 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
๐Ÿ‘คJ. Ghyllebert

1๐Ÿ‘

Sure you can

class SingleImageInline(generic.GenericTabularInline):
   model = Image
   extra = 1
   max_num = 1
   can_delete = False
   verbose_name = "Logo"
   verbose_name_plural = "Logos"

Leave a comment