Admin site
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
| Attribute | Purpose |
|---|---|
chassis_brand_name | Brand title in the shell |
chassis_brand_logo_static_path | Static path to the logo and favicon. Defaults to admin/chassis/icon.svg |
sidebar_items | SidebarLinkOption / SidebarSectionOption tuple |
chassis_page_classes | Custom AdminPage subclasses |
chassis_permission_options | Extra PermissionOption declarations |
dashboard_component_classes | Dashboard component classes |
dashboard_blocks | DashboardBlockDTO layout |
navbar_button_classes | Extra navbar buttons |
user_menu_item_classes | Extra user-menu items |
show_recent_actions | Show Django recent actions on the index |
include_users_module | Register Users/Groups, sessions, login attempts, audit, profile pages |
include_users_sidebar | Prepend 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.2The 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
PermissionOptionfromchassis_permission_options - requires each page class to declare exactly one access contract
(
PermissionAdminPage,PersonalAdminPage, orSuperuserAdminPage) - rejects
PersonalAdminPageclasses that join navbar or dashboard groups - requires
PermissionAdminPage.permissionto be aview_*permission
Failures raise ImproperlyConfigured at site construction, not on the first
request.