考虑一下:
@admin.register(MyModel)
MyModelAdmin(admin.ModelAdmin):
fieldsets = [
('Field1', {'fields': ['field1']}),
('Field2', {'fields': ['field2']}),
...
]
list_display = ('field1', 'field2')
假设我的管理员有另一个模型:
@admin.register(AnotherModel)
AnotherModelAdmin(admin.ModelAdmin):
fieldsets = [
('Field1', {'fields': ['field3']}),
('Field2', {'fields': ['field4']}),
...
]
list_display = ('field3', 'field4')
因此,我需要将field3
中的AnotherModelAdmin
显示为MyModelAdmin
内联。
我该如何实现?