Admin Integration#

Overview#

The admin integration for django-simple-page is realized by a customized page modeladmin. This modeladmin is registered for the page model and will be used for all proxy page models. It provides the following features:

  • Let pages be orderable by drag and drop in the admin changelist view.

  • Let the user choose the type of the page before rendering the page’s add form.

  • Set the initial value of the hidden page_type field in the page add form.

  • Render an inline formset for each region of the page which allows to assign sections to the region and rearrange them via drag and drop.

For your own concrete page models you should use BasePageAdmin as a base class for your modeladmin. It will take care of rendering the inline formsets for regions and setting the appropriate value for the hidden page_type field.

Api Reference#

Region inline#

class simple_page.admin.BaseRegionInline(parent_model, admin_site)#

Bases: TabularInline

Inline for the PageSection model. Each region of a page gets its own inline table with sections belonging to that region. We use the django-reorder-items-widget to make the sections orderable via drag and drop within their region.

Mixins#

class simple_page.admin.GetPageModelMixin#

Bases: object

A mixin to get the page model based on a page_type url query parameter or the page_type field of the current page object.

class simple_page.admin.SetPageTypeMixin#

Bases: GetPageModelMixin

Set the initial value of the hidden page_type field in changeforms when adding a new page.

class simple_page.admin.ChoosePageTypeMixin#

Bases: GetPageModelMixin

Let the user choose the type of the page she wants to add. Therefore render a simple list of add-links which either set the page_type url-query parameter for proxy page models or link to the modeladmin changeform for concrete page models.

class simple_page.admin.RenderPageRegionsMixin#

Bases: GetPageModelMixin

Render a PageSection inline formset for each region of the page. Also make sure extra forms have the region’s name as initial value for the region form field.

ModelAdmins#

class simple_page.admin.PageAdmin(model, admin_site)#

Bases: SetPageTypeMixin, ChoosePageTypeMixin, RenderPageRegionsMixin, DraggableMPTTAdmin

The modeladmin for all proxy page models. This modeladmin is already registered for the page model. It provides the following features:

  • Let pages be orderable by drag and drop in the admin changelist view.

  • Let the user choose the type of the page before rendering the page’s add form.

  • Set the initial value of the hidden page_type field in the page add form.

  • Render an inline formset for each region of the page.

class simple_page.admin.BasePageAdmin(model, admin_site)#

Bases: SetPageTypeMixin, RenderPageRegionsMixin, ModelAdmin

Base class for modeladmins for concrete page models. It provides the following features:

  • Set the initial value of the hidden page_type field in the page add form.

  • Render an inline formset for each region of the page.