API Reference
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.
| Attribute | Type | Default |
|---|---|---|
options | list[AdminOption] | [RowActionsOption()] |
chassis_settings | Settings | Settings() |
chassis_link_first_column | bool | False |
change_list_template | str | admin/chassis/change_list.html |
change_form_template | str | admin/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.21Complete 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.
| Class | Required parameters |
|---|---|
SearchOption | fields |
FiltersOption | fields |
DateHierarchyOption | field |
FieldTabsOption | field, choices |
ForeignKeyTabsOption | groups or field+model |
ForeignKeyTabGroupOption | field, model |
BadgeFieldsOption | fields |
CopyableFieldsOption | fields |
PrettyJsonOption | fields |
DecimalAmountOption | fields |
RelatedFieldsOption | fields |
RelatedFieldOption | field, label; optional help_text, empty_value_display |
RelatedCollectionsOption | collections |
RelatedCollectionOption | model, foreign_key, value_field, label; optional field_class, widget_attrs, save_method |
RowActionsOption | actions optional |
RowActionOption | action_type, label, color, icon_class |
ListActionsOption | actions |
ListActionOption | url_name, label |
ObjectActionsOption | actions optional, dropdown optional |
ObjectActionsDropdownOption | actions |
RelatedEntitiesOption | sections |
RelatedEntityOption | slug, title, get_items_method, table |
TableOption | columns |
TableColumnOption | field, label |
TableActionOption | url_name, label, icon_class |
TableActionUrlKwargOption | name, value |
ImportOption | permission |
ExportOption | permission |
Settings | all optional |
PermissionOption | app_label, model, codename, name |
AdminPageGroupOption | slug, label, icon_class |
SidebarSectionOption | slug, label, icon_class, items |
SidebarModelItemOption | model |
SidebarPageItemOption | page_slug |
SidebarLinkOption | slug, 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.
chassis_related_items
Marks a ModelAdmin classmethod as a related-table provider. Signature:
(cls, request, obj) -> QuerySet | Sequence.
Pages
from django_chassis.views import ...
| Class | Access |
|---|---|
AdminPage | abstract base |
PermissionAdminPage | permission: PermissionOption starting with view_ |
PersonalAdminPage | authenticated staff; no navbar/dashboard groups |
SuperuserAdminPage | active superuser |
AdminInformationPage | structured sections / alerts / timelines |
AdminObjectPage[T] | list/object routes plus object actions |
UserCreationAdminPage | users-module page; own and manage-access permissions plus User view/add/change |
Dashboard components
from django_chassis.components import ...
| Class | Implement |
|---|---|
DashboardComponent | as_dto() (abstract) |
DashboardMetric | get_value() |
DashboardChart | get_data() -> DashboardChartDataDTO |
DashboardAlert | visibility + message |
DashboardAction | routed action body |
DashboardToggleAction | true/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.
Modal components
Added in 1.0.7AdminModal 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.9AdminTreeDTO(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.
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)
| Enum | Members |
|---|---|
RowActionType | view, change, delete, history |
RowActionDisplay | icon, button |
TabDisplay | buttons, select |
PermissionCheck | group_only, user_has_perm |
ImportFormat | JSON, XML |
ExportFormat | JSON, XML, CSV, XLSX |
ImportBackend / ExportBackend | PYTHON_QUEUE, INLINE, WORKER (CELERY alias) Changed in 1.0.19 |
DashboardBlockType | alerts, metrics, actions, metrics_and_actions, chart |
DashboardComponentStatus | active, disabled, hidden, error |
DashboardMetricResultType | single value / table / stacked |
ButtonColor | primary, secondary, success, danger, … |
See also
Background task API
Added in 1.0.19WorkerProvider, WorkerTaskDTO, WorkerService: Background tasks.