使用在模型之后加载的表单自定义 Wagtail 编辑界面

Customize the Wagtail editing interface with a form that is loaded after the model

我想自定义文档中定义的 Wagtail 编辑界面:

http://docs.wagtail.io/en/v1.11.1/advanced_topics/customisation/page_editing_interface.html#customising-generated-forms

问题是我的表单有一个带有查询集的字段,该查询集从模型中获取对象,因此我将 运行 保持在循环依赖关系中。

如何定义 base_form_class 之后 加载模型?有什么解决办法吗?

想通了!简单明了的解决方案是在 class.

之外定义模型属性
class EventPage(Page):
    ...
    # Instead of:
    # base_form_class = EventPageForm

class EventPageForm(WagtailAdminPageForm):
    ...

EventPage.base_form_class = EventPageForm