1

我正在尝试完成一个非常简单的任务,即在管理面板的末尾没有出现内联。我没有问题让内联出现在最后,但这不是我想要的。我正在寻找一种方法来控制类的其他属性中内联的顺序?

到目前为止,我用谷歌搜索它没有运气。有任何想法吗?

class MyInlineAdmin(admin.StackedInline):
    ...

class MyModelAdmin(admin.ModelAdmin):

    inlines = [MyInlineAdmin]

    fieldsets = [
        ("Some Label", {
                "fields": ["field1", "field2"]
            }),
        ("Other Label", {
            "fields": ["field3", "field4"]
        })
    ]
4

1 回答 1

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)
于 2013-08-01T18:03:13.920 回答