Customizing the admin interface

The admin rendering of a page type is fully customizable.

Changed in version 1.2: It’s no longer necessary to define the model_admin attribute. Registering the custom admin class instead using admin.site.register() or the @admin.register() decorator.

@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  # only required for fluent-pages 1.1 and below.

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

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
from .models import ProductCategoryPage


@admin.register(ProductCategoryPage)
class ProductCategoryPageAdmin(PageAdmin):
    raw_id_fields = PageAdmin.raw_id_fields + ('product_category',)

Despire being registered in the admin, the model won’t show up in the index page. The “list” page is never used, as this is rendered by the main PageAdmin class. Only the “add” and “edit” page are exposed by the PageAdmin class too.

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.