【问题标题】:Customize the Wagtail editing interface with a form that is loaded after the model使用模型后加载的表单自定义 Wagtail 编辑界面
【发布时间】:2017-07-24 21:12:42
【问题描述】:

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

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

问题是我的表单有一个带有查询集的字段,该查询集从模型中获取对象,所以我一直遇到循环依赖。

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

【问题讨论】:

    标签: django wagtail


    【解决方案1】:

    想通了!简单明了的解决方案是在类之外定义模型属性。

    class EventPage(Page):
        ...
        # Instead of:
        # base_form_class = EventPageForm
    
    class EventPageForm(WagtailAdminPageForm):
        ...
    
    EventPage.base_form_class = EventPageForm
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-25
      • 1970-01-01
      • 1970-01-01
      • 2014-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多