Skip to main content

Sidebar

Added in 1.0.1

The sidebar is declared on the AdminSite, not discovered from INSTALLED_APPS. AdminSidebarService resolves model and page references, applies permissions, and computes the active/expanded state.

Options

from django.utils.translation import gettext_lazy as _

from django_chassis.enums import SidebarIconColor
from django_chassis.options import (
SidebarLinkOption,
SidebarModelItemOption,
SidebarPageItemOption,
SidebarSectionOption,
)


class CustomAdminSite(ChassisAdminSiteMixin, AdminSite):
sidebar_items = (
SidebarLinkOption(slug='docs', label=_('Documentation'), icon_class='fa-solid fa-book', url_name='admin:index'),
SidebarSectionOption(
slug='catalog',
label=_('Catalog'),
icon_class='fa-solid fa-boxes-stacked',
icon_color=SidebarIconColor.SLATE,
items=[SidebarModelItemOption(model='catalog.book'), SidebarPageItemOption(page_slug='inventory')],
),
)

SidebarSectionOption

ParameterTypeDefault
slugstrrequired
labellocalized stringrequired
icon_classFont Awesome classrequired
itemsmodel or page childrenrequired
icon_colorSidebarIconColorSLATE

SidebarModelItemOption

ParameterTypeDefault
model'app_label.model'required
labellocalized string or Nonemodel verbose name
icon_classFont Awesome classfa-solid fa-table-list

The model must be registered on the same AdminSite. Users without model permissions do not see the item.

SidebarPageItemOption

ParameterTypeDefault
page_slugstrrequired
labellocalized string or Nonepage label
icon_classFont Awesome class''

The page must be listed in chassis_page_classes and must be a PermissionAdminPage. PersonalAdminPage and SuperuserAdminPage cannot be sidebar children.

SidebarLinkOption

A standalone URL, not a section.

ParameterTypeDefault
slugstrrequired
labellocalized stringrequired
icon_classFont Awesome classrequired
url_nameDjango URL namerequired

Behaviour

  • Duplicate slugs and unknown model/page references fail validation.
  • The stock Django nav sidebar is disabled (enable_nav_sidebar = False).
  • Active/expanded state is computed from the current URL.
  • With include_users_module and include_users_sidebar (defaults), Chassis prepends the Users and groups section. Product roles are not included. See Users and access.

See also