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()
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.

Added in 1.0.23

BooleanChoiceSwitch, CodeEditor, PermissionGrid, TransferSelect, TranslateWidget and UnitInput are exported from django_chassis.widgets. The document editor form fields are exported from django_chassis.forms. 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
EntityPickerOptionfields Added in 1.0.23
FieldHistoryOptionfields Added in 1.0.23
FormBlockOptiontitle, fields Added in 1.0.23
FormLayoutOptionblocks Added in 1.0.23
PageBreadcrumbOptionlabel Added in 1.0.23
PageHeaderOptionAdded in 1.0.23 All optional
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, and exactly one of value_field or nonempty fields Changed in 1.0.23
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
ImportOptionview_permission, upload_permission Changed in 1.0.23
ExportOptionview_permission, create_permission, download_permission Changed in 1.0.23
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

The transfer permissions above are required for an enabled flow. The legacy permission argument is accepted for compatibility and grants no access. An empty formats list or ExportOption.filter_fields list raises ValueError.

Decorators​

object_action​

from django_chassis.decorators import object_action

@object_action(
description,
*,
permission=None,
confirmation=None,
color=ButtonColor.PRIMARY,
icon_class=None,
opens_modal=False,
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(request) -> DashboardChartDataDTO
DashboardCardget_data(request, period) -> DashboardCardDTO Added in 1.0.23
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, observed_at=None) accepts a finite Decimal or None for a gap. See Dashboard for DashboardCardDTO, DashboardPeriodDTO and the static card options.

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 Changed in 1.0.23
DashboardBlockTypealerts, metrics, actions, metrics_and_actions, chart, card
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.

Accounts, localization and notifications​

Added in 1.0.23
ImportUse
django_chassis.services.UserProfileServiceAccount profile and optional phone.
django_chassis.services.ImpersonationServiceIssue, redeem, validate and finish website delegation.
django_chassis.services.LanguageService, TranslationServiceManage languages and read localized text.
django_chassis.fields.TranslateFieldStore localized model values with per-language controls.
django_chassis.dto.global_alert.GlobalAlertDTOSupply notifications from a callable or signal receiver.
django_chassis.options.PageHeaderOption, FormLayoutOption, FieldHistoryOptionConfigure titles, fieldsets and the history comparison.
django_chassis.options.EntityPickerOptionEnable a permission-aware foreign key autocomplete.

For the WizardAdminPage and WizardStepDTO contracts, see multi-step admin pages.

Transfer backend compatibility​

Changed in 1.0.23

Use ImportBackend.WORKER and ExportBackend.WORKER for jobs sent to the configured worker provider. Both use stored value 3. Replace imports from django_chassis.tasks.process_import_export with IMPORT_EXPORT_TASK from django_chassis.worker_tasks. The backend setup covers registration and dispatch.

Account, request, and deployment integration​

Import the service classes below from django_chassis.services. Import AccountAction from django_chassis.models, ConfirmedActionForm from django_chassis.forms, and names ending in DTO from django_chassis.dto. Import AccountActionType, AdminAuditAction, AdminAuditResult, PermissionNameLanguage and UserSessionEndReason from django_chassis.enums. Use the documented Admin views for request permissions and user confirmation.

APIPurpose
AccountActionService, AccountActionType, AccountActionApply audited account transitions. The built-in role and status handlers validate the operator and the requested transition before writing.
UserAdminAccessService, UserAdminCreationService, UserModelServiceEnforce the built-in access rules, create supported user accounts, and resolve the configured model's identifier and personal fields.
UserProfileService, AdminProfileService, AdminProfileDTO, UserProfileActivityDTOCollect stored profile, contact and activity data. The Admin profile composes those fields with the current session and recent audited actions.
UserSessionService, UserSessionEndReason, SessionKeyCryptoServiceRegister, locate, touch or terminate Chassis-tracked sessions. The crypto service protects the stored session-key value used for revocation.
LoginAttemptLimitService, LoginAttemptAvailabilityDTOEvaluate retry availability for an account and client scope, persist attempts and manage the configured attempt cycle.
AdminAuditLogService, AdminAuditAction, AdminAuditResult, RequestClientMetadataDTOCapture request metadata and finish an audit record with its outcome. The standard audit middleware manages the lifecycle.
ClientIpService, ClientDeviceService, ClientDeviceDTO, ClientGeoIpServiceResolve trusted client addresses, identify browser and OS, and look up a country from a local GeoIP database.
PermissionInitializationService, ActionPermissionValidationService, PermissionNameNormalizationService and PermissionNameLanguageInitialize and validate declared codes and normalize human-readable permission names. Register project declarations with PermissionRegistry.register(PermissionOption(...)).
ConfirmedActionService, ConfirmedActionFormRender the shared confirmation workflow for actions that explicitly opt into that service. A ModelAdmin object action defines its own request handling.
DeletedObjectsServiceCollect related objects used to present a deletion summary. The project's access and deletion policy determines when deletion can proceed.

For example, an Admin integration can reuse Chassis client resolution without reading proxy headers independently.

from django.http import HttpRequest

from django_chassis.services import ClientIpService


def client_address(request: HttpRequest) -> str | None:
return ClientIpService.get_client_ip(request=request)

Set CHASSIS_TRUSTED_PROXY_NETWORKS only for verified proxy peers. AdminErrorPageMiddleware delegates eligible Admin HTML errors to AdminErrorPageRenderer, which uses status-specific text from AdminErrorStatus. The error shell can retain ThemeAdminNavbarButton, the built-in control for light, dark and system appearance. See settings and checks.

Register GeoIpDatabaseDashboardAlert in the dashboard component list and place its slug in an alert block when superusers need an in-dashboard warning about a missing or unreadable GEOIP_COUNTRY_DATABASE_PATH. The project still configures the local database. See dashboard blocks.

Transfer persistence and processing​

APIPurpose
ImportFieldDTO, ExportFieldDTO, ExportFilterDTO, ImportExportFieldService, ExportFilterServiceDescribe fields, resolve filter lookups and enforce the configured allowlists.
ImportPreviewDTO, ImportPreviewRowDTO, ImportPreviewSkippedRowDTO, ImportApplyServiceValidate mappings and rows and report accepted, skipped and invalid input. The apply stage persists the batch.
ImportExportScopeService, ImportStatus, ExportStatusResolve the site and model that own a transfer and represent its persisted state. Legacy import PREVIEW records may remain after an upgrade.
ImportExportSerializationServiceParse the supported input formats and serialize exported records. Use the normal transfer flow to apply storage, fields and permissions.
ImportExportProcessService, ImportExportTaskServiceExecute submitted operations. Use ImportExportDispatchService to submit work through Chassis.
WorkerService.is_available(), CeleryWorkerProvider.is_available()Check the configured provider or Celery specifically. Use PythonQueueWorkerProvider for the process-local queue. Changed in 1.0.23

The GlobalAlertRead receipt belongs to one user and notification identifier. GroupMembership records when and by whom a tracked group assignment was made. ImpersonationGrant stores the state of the short-lived delegation managed by ImpersonationService. These records back the corresponding workflows described in notifications and account administration.

Presentation contracts​

  • SidebarChildOption represents either a model or a custom-page sidebar entry. AdminSidebarItemDTO and AdminSidebarChildItemDTO carry resolved navigation.
  • AdminNavbarItemDTO and AdminNavbarItemType identify buttons, dropdowns and theme controls. AdminModalDTO carries the registered modal's trigger details.
  • DashboardChartDTO, DashboardAlertDTO, DashboardMetricDTO and DashboardActionDTO describe rendered widgets. DashboardLiveWidgetType, DashboardSourceState, DashboardStackedItemDTO and DashboardStackedItemTone describe live payload kinds, source states and stacked data. See dashboard metrics and charts.
  • render_boolean emits the standard Admin boolean representation. Use DisplayState for components that present semantic status.
  • DATE_INPUT_FORMAT, TIME_INPUT_FORMAT, and DATETIME_INPUT_FORMAT are input formats. Their corresponding *_MASK and *_PLACEHOLDER constants support the date and time widgets.
  • See UI components for the complete set of workspace DTOs that render through the chassis_component template tag.