我正在尝试完成在管理面板末尾没有显示内联的非常简单的任务。我没有问题在最后显示内联,但这不是我想要的。我正在寻找一种方法来控制类的其他属性内联的排序?
到目前为止,我一直用Google搜索,没有运气。有什么想法吗?
class MyInlineAdmin(admin.StackedInline):
...
class MyModelAdmin(admin.ModelAdmin):
inlines = [MyInlineAdmin]
fieldsets = [
("Some Label", {
"fields": ["field1", "field2"]
}),
("Other Label", {
"fields": ["field3", "field4"]
})
]
答案 0 :(得分:0)
试试这个:
class MyInlineAdmin(admin.StackedInline):
model = Child_model
ordering = [’child1’, ’child2’]
class MyModelAdmin(admin.ModelAdmin):
model = Parent_Model
inlines = [MyInlineAdmin]
fieldsets = [
("Some Label", {
"fields": ["field1", "field2"]
}),
("Other Label", {
"fields": ["field3", "field4"]
})
]
admin.site.register(Parent_Model,MyModelAdmin)