Skip to main content

API Reference

Added in 1.0.1

Manual reference for the public exports. Import from the subpackages, not from django_chassis itself.

from django_chassis.mixins import ChassisAdminMixin, ChassisAdminSiteMixin
from django_chassis.options import SearchOption, RowActionsOption
from django_chassis.components import DashboardMetric
from django_chassis.views import PermissionAdminPage
from django_chassis.decorators import object_action

Mixins​

ChassisAdminMixin​

from django_chassis.mixins import ChassisAdminMixin

Must precede ModelAdmin in the MRO.

AttributeTypeDefault
optionslist[AdminOption][RowActionsOption()]
chassis_settingsSettingsSettings()
chassis_link_first_columnboolFalse
change_list_templatestradmin/chassis/change_list.html
change_form_templatestradmin/chassis/change_form.html

See ModelAdmin.

ChassisAdminSiteMixin​

from django_chassis.mixins import ChassisAdminSiteMixin

Must precede AdminSite in the MRO.

Key attributes: chassis_brand_name, chassis_brand_logo_static_path, chassis_brand_favicon_static_path, sidebar_items, chassis_page_classes, chassis_permission_options, chassis_modal_classes, dashboard_component_classes, dashboard_blocks, navbar_button_classes, user_menu_item_classes, show_recent_actions, include_users_module, include_users_sidebar.

Hooks: get_dashboard_service(), get_navbar_service(), get_chassis_modal_service(), get_chassis_page_service(), get_sidebar_service(), get_sidebar_items(), get_users_sidebar_section(), get_chassis_brand(), get_chassis_brand_badge(), get_chassis_footer_context().

Users module: Users and access.

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.

ReadOnlyAdminMixin / NoDeleteAdminMixin​

Deny add/change/delete, or only delete.

Form widgets​

CopyableTextInput​

Added in 1.0.18

from django_chassis.widgets import CopyableTextInput

Editable text input with a copy button and configurable prefix. The prefix is included in copied text but excluded from the submitted form value. See Form widgets.

Options​

All option classes are frozen dataclasses. Field-by-field purpose, defaults, validation, and UI region: Options catalog.

ClassRequired parameters
SearchOptionfields
FiltersOptionfields
DateHierarchyOptionfield
FieldTabsOptionfield, choices
ForeignKeyTabsOptiongroups or field+model
ForeignKeyTabGroupOptionfield, model
BadgeFieldsOptionfields
CopyableFieldsOptionfields
PrettyJsonOptionfields
DecimalAmountOptionfields
RelatedFieldsOptionfields
RelatedFieldOptionfield, label; optional help_text, empty_value_display
RelatedCollectionsOptioncollections
RelatedCollectionOptionmodel, foreign_key, value_field, label; optional field_class, widget_attrs, save_method
RowActionsOptionactions optional
RowActionOptionaction_type, label, color, icon_class
ListActionsOptionactions
ListActionOptionurl_name, label
ObjectActionsOptionactions optional, dropdown optional
ObjectActionsDropdownOptionactions
RelatedEntitiesOptionsections
RelatedEntityOptionslug, title, get_items_method, table
TableOptioncolumns
TableColumnOptionfield, label
TableActionOptionurl_name, label, icon_class
TableActionUrlKwargOptionname, value
ImportOptionpermission
ExportOptionpermission
Settingsall optional
PermissionOptionapp_label, model, codename, name
AdminPageGroupOptionslug, label, icon_class
SidebarSectionOptionslug, label, icon_class, items
SidebarModelItemOptionmodel
SidebarPageItemOptionpage_slug
SidebarLinkOptionslug, label, icon_class, url_name, icon_color

ImportOption / ExportOption raise ValueError when permission is blank or when formats / filter_fields is an empty list.

Decorators​

object_action​

from django_chassis.decorators import object_action

@object_action(
description,
*,
permission=None,
confirmation=None,
color=ButtonColor.PRIMARY,
icon_class=None,
condition=None,
condition_method=None,
)

condition and condition_method are mutually exclusive. See Object actions.

Marks a ModelAdmin classmethod as a related-table provider. Signature: (cls, request, obj) -> QuerySet | Sequence.

Pages​

from django_chassis.views import ...

ClassAccess
AdminPageabstract base
PermissionAdminPagepermission: PermissionOption starting with view_
PersonalAdminPageauthenticated staff; no navbar/dashboard groups
SuperuserAdminPageactive superuser
AdminInformationPagestructured sections / alerts / timelines
AdminObjectPage[T]list/object routes plus object actions
UserCreationAdminPageusers-module page; own and manage-access permissions plus User view/add/change

Dashboard components​

from django_chassis.components import ...

ClassImplement
DashboardComponentas_dto() (abstract)
DashboardMetricget_value()
DashboardChartget_data() -> DashboardChartDataDTO
DashboardAlertvisibility + message
DashboardActionrouted action body
DashboardToggleActiontrue/false variants

Shared fields: slug, label, order, status.

DashboardBlockDTO(slug, title, block_type, component_slugs, row=1, group='default', size=4, order=100, is_global=False, live_refresh_interval_seconds=None)

DashboardChartDataDTO(value, period_label, series, unit=None) DashboardChartSeriesDTO(label, color, points) DashboardChartPointDTO(label, value) — value is Decimal.

Added in 1.0.7

AdminModal defines a lazy GET/POST fragment with custom has_view_permission(). PermissionAdminModal supplies that check from a registered PermissionOption. Both are exported from django_chassis.components; see Modal components.

AdminModal.max_width optionally constrains a dialog with a viewport-bounded CSS length.

Presentation DTOs and renderers​

Added in 1.0.9

AdminTreeDTO(nodes, label, empty_text) and AdminTreeNodeDTO(label, children=[], icon_class=None, badge=None) are exported from django_chassis.dto. render_admin_tree(tree=...) and render_field_help(label=..., help_text=...) are exported from django_chassis.renderers.

Services​

Public service classes are explicit package exports and can be imported from django_chassis.services:

from django_chassis.services import DashboardService, TableService

AdminModalService registers modal classes, exposes their protected URLs, and builds the permission-filtered trigger context.

Added in 1.0.7

PaginationService.build_keyset(...) adapts cursor pagination to the same pages, result_count, and localized object_name template contract as PaginationService.build(...). Supply the current request, page result count, next cursor, and the cursor, cursor-history, and page parameter names. PaginationService.build(...) accepts optional base_url for links that target a fragment endpoint, including modal pagination.

Permissions​

from django_chassis.permissions import has_request_user_permission

has_request_user_permission(request, 'catalog.view_book') -> bool

Setting: CHASSIS_PERMISSION_CHECK = 'group_only' | 'user_has_perm'.

Enums (selected)​

EnumMembers
RowActionTypeview, change, delete, history
RowActionDisplayicon, button
TabDisplaybuttons, select
PermissionCheckgroup_only, user_has_perm
ImportFormatJSON, XML
ExportFormatJSON, XML, CSV, XLSX
ImportBackend / ExportBackendPYTHON_QUEUE, INLINE, WORKER (CELERY alias) Changed in 1.0.19
DashboardBlockTypealerts, metrics, actions, metrics_and_actions, chart
DashboardComponentStatusactive, disabled, hidden, error
DashboardMetricResultTypesingle value / table / stacked
ButtonColorprimary, secondary, success, danger, …

See also​

Background task API​

Added in 1.0.19

WorkerProvider, WorkerTaskDTO, WorkerService: Background tasks.