Django管理员嵌入内联而没有标题

时间:2015-01-22 20:07:35

标签: django django-templates django-admin

我正在使用https://github.com/s-block/django-nested-inline

让我们说我的模特是Top,2nd,2ndA和2ndB。 顶部和第二个是一对多,而2ndA和2ndB是一对一的第二个。

我的应用管理员看起来像这样:

from django.contrib import admin
from nested_inline.admin import NestedStackedInline, NestedModelAdmin
from myapp.models import Top, 2nd, 2ndA, 2ndB

class 2ndAInline(NestedStackedInline):
    model = 2ndA
    extra = 1
    fk_name = '2ndA'
    template = 'admin/myapp/edit_inline/stacked-nested.html'

class 2ndBInline(NestedStackedInline):
    model = 2ndB
    extra = 1
    fk_name = '2ndB'
    fieldsets = [
        ('Follow up notes', {'fields': ['followup_notes'],'classes': ['collapse']}),
    ]
    template = 'admin/myapp/edit_inline/stacked-nested.html'

class 2ndInline(NestedStackedInline):
    model = 2nd
    extra = 1
    fk_name= 'Top'
    inlines = [2ndA, 2ndB]
    template = 'admin/myapp/edit_inline/stacked-nested.html'

class TopAdmin(NestedModelAdmin):
    model = Top
    inlines = [2ndInline]

admin.site.register(Top, TopAdmin)

它有效,但我想摆脱不必要的标题,例如" 2ndA:#1",因为只会有一个条目。

我已尝试覆盖模板,但是当我从h3标签中删除任何内容时,它适用于第一个内联,但后续的内联似乎不会使用我指定的模板,而是以某种方式成为表格......

非常感谢

0 个答案:

没有答案