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; preserves its natural aspect ratio. Defaults to admin/chassis/icon.svg |
chassis_brand_favicon_static_path | Separate favicon; None falls back to the logo |
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 |
chassis_modal_classes | Reusable AdminModal component classes |
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 |
CHASSIS_USERS_MODULE_ENABLED = False globally disables the built-in users
runtime even when include_users_module remains True on a site.
Complete logos
Changed in 1.0.21 Added in 1.0.21Use a complete logo containing the project name and disable the separate text caption. Images preserve their aspect ratio at 22px height in the sidebar and 30px on login. The optional chassis_brand_favicon_static_path selects a separate square icon; omitting it preserves the existing logo-as-favicon behavior.
chassis_brand_name = None
chassis_brand_logo_static_path = 'img/full-logo.svg'
chassis_brand_favicon_static_path = 'img/favicon.svg'
Service hooks
Override these when you need a custom service implementation:
get_dashboard_service()get_navbar_service()get_chassis_modal_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 - validates modal classes and registers permissions declared by
PermissionAdminModal
Failures raise ImproperlyConfigured at site construction, not on the first
request.