Skip to main content

Dashboard

Added in 1.0.1 Changed in 1.0.9

The Admin index is a dashboard. You declare components and place them in blocks on a four-column grid. DashboardService validates the layout and renders SSR context. Live widgets refresh through dashboard/live/.

Index template: admin/chassis/dashboard/index.html (extends admin/index.html). Set index_template only if you replace the whole page.

Page anatomy​

┌─ navbar (theme, custom buttons, page-group dropdowns, user menu) ─┐
├─ sidebar (declared sidebar_items) ─────────────────────────────────┤
├─ alert strip (`nav-breadcrumbs` override) ─────────────────────────┤
│ global / alert blocks (`is_global=True`, ALERTS only) │
├─ main grid (`admins-dashboard-layout`) ────────────────────────────┤
│ row 1: block size 2 + block size 2 │
│ row 2: block size 4 (full width) │
│ … │
│ optional aside: Django "Recent actions" (`show_recent_actions`) │
└────────────────────────────────────────────────────────────────────┘

Each block includes templates/admin/chassis/dashboard/sections/*.html for its DashboardBlockType. Charts load ApexCharts. Live widgets poll {% url 'admin:dashboard_live' %} with If-None-Match.

If dashboard_component_classes is empty, the shell still renders: brand, sidebar, navbar, and an empty grid.

Components and blocks​

Set dashboard_component_classes and dashboard_blocks on the AdminSite as lists or tuples.

from django.utils.translation import gettext_lazy as _

from django_chassis.dto import DashboardBlockDTO
from django_chassis.enums import DashboardBlockType


class CustomAdminSite(ChassisAdminSiteMixin, AdminSite):
dashboard_component_classes = (OpenOrdersMetric, RevenueChart, NightlyImportAlert, RebuildSearchAction)
dashboard_blocks = (
DashboardBlockDTO(
slug='alerts',
title=_('Alerts'),
block_type=DashboardBlockType.ALERTS,
component_slugs=('nightly-import',),
row=1,
size=4,
is_global=True,
),
DashboardBlockDTO(
slug='kpis',
title=_('Overview'),
block_type=DashboardBlockType.METRICS,
component_slugs=('open-orders',),
row=2,
group='kpis',
size=2,
live_refresh_interval_seconds=30
),
DashboardBlockDTO(
slug='revenue',
title=_('Revenue'),
block_type=DashboardBlockType.CHART,
component_slugs=('revenue',),
row=2,
group='revenue',
size=2,
),
)

DashboardBlockDTO​

ParameterTypeDefault
slugunique block idrequired
titlelocalized stringrequired
block_typeDashboardBlockTyperequired
component_slugsslugs of components in this blockrequired
rowgrid row1
grouplayout group'default'
size1–4 columns4
ordersort inside the row100
is_globalspan the full widthFalse
live_refresh_interval_secondspositive integer or NoneNone — no polling

DashboardBlockType: alerts, metrics, actions, metrics_and_actions, chart, card.

Layout rules​

Key/value information cards in dashboard components use the same panel headers as metric blocks, with bold labels and slightly smaller, regular-weight values aligned to opposite edges.

  • The grid has four columns. Blocks with the same row and group stack vertically and must share the same size. Distinct groups in a row sit side by side and span at most four columns in total.
  • A chart block contains exactly one chart. A card block takes one DashboardCard, or an empty component_slugs sequence to render a static card. Other empty blocks are omitted.
  • Unknown slugs and repeated assignments fail validation.
  • Only alert blocks may set is_global=True.

Live endpoint​

Only blocks with live_refresh_interval_seconds set are polled. Each block uses its own timer, request, and ETag; successful reads animate only that block and respect prefers-reduced-motion.

GET {admin}/dashboard/live/?section=<block-slug> returns the current snapshot for one live-enabled block. Repeat section to request multiple blocks or omit it to request all live blocks. Send If-None-Match to receive 304 when the ETag has not changed. DashboardLiveSerializationService builds deterministic ETags.

Widgets carry etag, fetched_at, and next_refresh_at when the component provides them.

Visibility​

Every component inherits:

  • slug, label, order, status
  • check_view(request) / check_use(request)
  • is_visible(request) hides HIDDEN components for everyone. is_available(request) requires ACTIVE status. Superusers bypass check_view and check_use.

See Dashboard metrics and charts for the concrete component contracts.

See also​

Donut chart​

Added in 1.0.20

Use DashboardChartType.DONUT for a distribution. Each DashboardChartSeriesDTO represents one named slice and contains exactly one non-negative point. The existing DTO, live refresh, permissions and theme contracts remain the same.

Data cards and live periods​

Added in 1.0.23

Subclass DashboardCard from django_chassis.components and implement get_data(self, request, period) -> DashboardCardDTO. Return the registered slug, a label and a workspace DTO in content. Register the source in dashboard_component_classes and place its slug in the component_slugs of a DashboardBlockDTO with block_type=DashboardBlockType.CARD. For a static card, pass an empty sequence and use card_value, card_hint and card_delta. Use template_name to supply a custom block template.

Declare supported calendar periods using periods, for example ('7d', '30d', '90d'). The first declared value is the default. A nonempty period_<slug> query parameter takes priority over period. Unsupported periods are rejected. A source with no declared periods receives None. DashboardPeriodDTO exposes half-open bounds ending at the next midnight in Django's active timezone and the bounds of the preceding period. The built-in templates leave period selection to the project. A DashboardChart continues to receive only request and may call DashboardPeriodDTO.from_request() to implement its own period handling.

Cards and charts can declare periods as a list or tuple. Charts can pass this sequence directly to DashboardPeriodDTO.from_request().

Set dashboard_show_toolbar=True on the AdminSite for pause and manual refresh. Set live_refresh_interval_seconds on each block you want to refresh. Authorized data cards can report DashboardSourceState.DATA, EMPTY, LOADING, STALE or UNAVAILABLE. Use observed_at for when the source observed a value and fetched_at for when it was retrieved. An observed zero remains a numeric value. A live card retains its previous content when a refresh reports LOADING or UNAVAILABLE.