Customizing the admin interface

The admin rendering of a page type is fully customizable.

@page_type_pool.register
class ProductCategoryPagePlugin(PageTypePlugin):
    """"
    A new page type plugin that binds the rendering and model together.
    """
    model = ProductCategoryPage
    render_template = "products/productcategorypage.html"

    model_admin = ProductCategoryPageAdmin

The admin class needs to inherit from one of the following classes:

  • fluent_pages.admin.PageAdmin
  • fluent_pages.admin.HtmlPageAdmin - in case the model extends from HtmlPage
  • fluent_pages.pagetypes.fluentpage.admin.FluentPageAdmin - in case the model extends from FluentPageBase

The admin can be used to customize the “add” and “edit” fields for example:

from django.contrib import admin
from fluent_pages.admin import PageAdmin

class ProductCategoryPageAdmin(PageAdmin):
    raw_id_fields = PageAdmin.raw_id_fields + ('product_category',)

The “list” page is never used, as this is rendered by the main PageAdmin class.

Customizing fieldsets

To deal with model inheritance, the fieldsets are not set in stone in the fieldsets attribute. Instead, the fieldsets are created dynamically using the the base_fieldsets value as starting point. Any unknown fields (e.g. added by derived models) will be added to a separate “Contents” fieldset.

The default layout of the PageAdmin class is:

base_fieldsets = (
    PageAdmin.FIELDSET_GENERAL,
    PageAdmin.FIELDSET_MENU,
    PageAdmin.FIELDSET_PUBLICATION,
)

The default layout of the HtmlPageAdmin is:

base_fieldsets = (
    HtmlPageAdmin.FIELDSET_GENERAL,
    HtmlPageAdmin.FIELDSET_SEO,
    HtmlPageAdmin.FIELDSET_MENU,
    HtmlPageAdmin.FIELDSET_PUBLICATION,
)

The title of the custom “Contents” fieldset is configurable with the extra_fieldset_title attribute.

Customizing the form

Similar to the base_fieldsets attribute, there is a base_form attribute to use for the form.

Inherit from the PageAdminForm class to create a custom form, so all base functionality works.