- class wagtail.admin.panels.Panel(heading='', classname='', help_text='', base_form_class=None, icon='')¶
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
modelattribute pointing to the linked model class.
Called after the panel has been associated with a model class and the
self.modelattribute 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
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, prefix='panel')¶
BoundPanelinstance that can be rendered onto the template as a component. By default, this creates an instance of the panel class’s inner
BoundPanelclass, which must inherit from
- property clean_name¶
A name for this panel, consisting only of ASCII alphanumerics and underscores, suitable for use in identifiers. Usually generated from the panel heading. Note that this is not guaranteed to be unique or non-empty; anything making use of this and requiring uniqueness should validate and modify the return value as needed.
- class wagtail.admin.panels.Panel.BoundPanel(panel, instance, request, form, prefix)¶
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 attributes and methods:
The panel definition corresponding to this bound panel
The model instance associated with this panel
The request object associated with this panel
The form object associated with this panel
A unique prefix for this panel, for use in HTML IDs
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.