Preston Horn
Preston Horn

Reputation: 231

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

I want to customize the Wagtail editing interface as defined in the docs:

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

The problem is that my form has a field with a queryset that gets objects from the model, so I keep running into circular dependencies.

How can I define a base_form_class that is loaded after the model? Any way around this?

Upvotes: 3

Views: 324

Answers (1)

Preston Horn
Preston Horn

Reputation: 231

Figured it out! The simple and obvious solution is to define model attribute outside of the class.

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

class EventPageForm(WagtailAdminPageForm):
    ...

EventPage.base_form_class = EventPageForm

Upvotes: 2

Related Questions