Panel API


class wagtail.admin.panels.Panel(heading='', classname='', help_text='', base_form_class=None)

Defines part (or all) of the edit form interface for pages and other models within the Wagtail admin. Each model has an associated panel definition, consisting of a nested structure of Panel objects - this provides methods for obtaining a ModelForm subclass, with the field list and other parameters collated from all panels in the structure. It then handles rendering that form as HTML.


Create a clone of this panel definition with a model attribute pointing to the linked model class.


Called after the panel has been associated with a model class and the self.model attribute is available; panels can override this method to perform additional initialisation related to the model.


Create a clone of this panel definition. By default, constructs a new instance, passing the keyword arguments returned by clone_kwargs.


Return a dictionary of keyword arguments that can be used to create a clone of this panel definition.


Return a dictionary of attributes such as ‘fields’, ‘formsets’ and ‘widgets’ which should be incorporated into the form class definition to generate a form that this panel can use. This will only be called after binding to a model (i.e. self.model is available).


Construct a form class that has all the fields and formsets named in the children of this edit handler.

get_bound_panel(instance=None, request=None, form=None)

Return a BoundPanel instance that can be rendered onto the template as a component. By default, this creates an instance of the panel class’s inner BoundPanel class, which must inherit from Panel.BoundPanel.


class wagtail.admin.panels.Panel.BoundPanel(panel, instance, request, form)

A template component for a panel that has been associated with a model instance, form, and request.

In addition to the standard template component functionality (see Creating components), this provides the following methods:


Returns an HTML ID to be used as the target for any label referencing this panel.


Whether this panel should be rendered; if false, it is skipped in the template output.