Skip to main content

Admin site

Added in 1.0.1

ChassisAdminSiteMixin attaches Chassis capabilities to a Django AdminSite. The application that owns the site instance declares brand, navigation, pages, and dashboard layout.

Minimal site

from django.contrib.admin import AdminSite
from django.utils.translation import gettext_lazy as _

from django_chassis.mixins import ChassisAdminSiteMixin


class CustomAdminSite(ChassisAdminSiteMixin, AdminSite):
chassis_brand_name = _('My project')
chassis_brand_logo_static_path = 'img/logo.png'


admin_site = CustomAdminSite(name='admin')

Mount admin_site.urls, not admin.site.urls.

Site-level option field tables (Sidebar*, AdminPageGroupOption, PermissionOption): Options catalog.

Site attributes

AttributePurpose
chassis_brand_nameBrand title in the shell
chassis_brand_logo_static_pathStatic path to the logo and favicon. Defaults to admin/chassis/icon.svg
sidebar_itemsSidebarLinkOption / SidebarSectionOption tuple
chassis_page_classesCustom AdminPage subclasses
chassis_permission_optionsExtra PermissionOption declarations
dashboard_component_classesDashboard component classes
dashboard_blocksDashboardBlockDTO layout
navbar_button_classesExtra navbar buttons
user_menu_item_classesExtra user-menu items
show_recent_actionsShow Django recent actions on the index
include_users_moduleRegister Users/Groups, sessions, login attempts, audit, profile pages
include_users_sidebarPrepend the standard Users and groups sidebar section

Service hooks

Override these when you need a custom service implementation:

  • get_dashboard_service()
  • get_navbar_service()
  • get_chassis_page_service()
  • get_sidebar_service()
  • get_chassis_brand() / get_chassis_brand_badge()
  • get_chassis_footer_context()

The mixin also attaches the users module unless include_users_module = False.

Third-party ModelAdmins

Changed in 1.0.2

The site wraps ordinary third-party ModelAdmin classes in ChassisAdminMixin so they pick up Chassis templates and default row actions. You still register those models on the Chassis site instance.

The register() signature uses the broad Django Model type so applications can override it without narrowing-override warnings from type checkers. ChassisAdminSiteMixin remains a pure runtime mixin; the project's AdminSite is the next class in the MRO and receives delegated Django calls.

Index template

index_template defaults to admin/chassis/dashboard/index.html. If you declare no dashboard components, the page still renders the Chassis shell.

Validation at construction

The mixin constructor:

  • registers every PermissionOption from chassis_permission_options
  • requires each page class to declare exactly one access contract (PermissionAdminPage, PersonalAdminPage, or SuperuserAdminPage)
  • rejects PersonalAdminPage classes that join navbar or dashboard groups
  • requires PermissionAdminPage.permission to be a view_* permission

Failures raise ImproperlyConfigured at site construction, not on the first request.

See also