Skip to main content

Navbar

Added in 1.0.1

The navbar is assembled by AdminNavbarService. It always includes the built-in theme item, then adds custom buttons, dropdowns from page groups, and the user menu.

Built-in theme item​

django_chassis.navbar.theme ships a theme switcher. You do not register it yourself; the navbar service inserts it.

Custom buttons and user-menu items​

Declare classes on the site:

from django_chassis.components import AdminNavbarButton, AdminUserMenuItem


class ReportsButton(AdminNavbarButton):
slug = 'reports'
label = 'Reports'
icon_class = 'fa-solid fa-chart-line'

def get_url(self, request):
return '/admin/pages/reports/'


class CustomAdminSite(ChassisAdminSiteMixin, AdminSite):
navbar_button_classes = (ReportsButton,)
user_menu_item_classes = ()

The users module adds Profile and Change password items unless include_users_module = False. See Users and access.

Slugs must be unique. The service validates that before rendering.

Available contracts:

  • AdminNavbarButton — a single link in the navbar
  • AdminNavbarDropdown — a parent with child items
  • AdminUserMenuItem — an item in the authenticated user menu
  • AdminNavbarItem — shared base

Page groups as dropdowns​

An AdminPage with navbar_group = AdminPageGroupOption(...) is collected into a navbar dropdown. Personal pages cannot join a group.

from django_chassis.options import AdminPageGroupOption

reports = AdminPageGroupOption(slug='reports', label='Reports', icon_class='fa-solid fa-chart-line', order=10)
ParameterTypeDefault
slugstrrequired
labellocalized stringrequired
icon_classFont Awesome classrequired
orderint0

The same option type is reused as dashboard_group for dashboard action sections. See Custom pages.

Changed in 1.0.7

Page-group dropdowns share the global navbar order with custom buttons. Dropdown child items with opens_modal=True render as modal triggers instead of links. See Modal components.

Brand​

Changed in 1.0.1

The site defaults to the documentation icon (admin/chassis/icon.svg) for the login brand and favicon. Override:

  • chassis_brand_name
  • chassis_brand_logo_static_path
  • chassis_brand_favicon_static_path

Or override get_chassis_brand() / get_chassis_brand_badge() to return BrandDTO / BrandBadgeDTO.

Changed in 1.0.21 Added in 1.0.21

Complete logos preserve their natural aspect ratio. Set chassis_brand_name = None when the image includes the name. Use chassis_brand_favicon_static_path or BrandDTO.favicon_static_path for a separate square favicon; None falls back to the logo.

See also​