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() |
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.
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.
| Class | Required parameters |
|---|---|
SearchOption | fields |
FiltersOption | fields |
DateHierarchyOption | field |
EntityPickerOption | fields Added in 1.0.23 |
FieldHistoryOption | fields Added in 1.0.23 |
FormBlockOption | title, fields Added in 1.0.23 |
FormLayoutOption | blocks Added in 1.0.23 |
PageBreadcrumbOption | label Added in 1.0.23 |
PageHeaderOption | Added in 1.0.23 All optional |
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, and exactly one of value_field or nonempty fields Changed in 1.0.23 |
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 | view_permission, upload_permission Changed in 1.0.23 |
ExportOption | view_permission, create_permission, download_permission Changed in 1.0.23 |
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 |
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.
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(request) -> DashboardChartDataDTO |
DashboardCard | get_data(request, period) -> DashboardCardDTO Added in 1.0.23 |
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, observed_at=None) accepts a finite Decimal or None for a gap. See Dashboard for DashboardCardDTO, DashboardPeriodDTO and the static card options.
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 Changed in 1.0.23 |
DashboardBlockType | alerts, metrics, actions, metrics_and_actions, chart, card |
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.
Accounts, localization and notifications
Added in 1.0.23| Import | Use |
|---|---|
django_chassis.services.UserProfileService | Account profile and optional phone. |
django_chassis.services.ImpersonationService | Issue, redeem, validate and finish website delegation. |
django_chassis.services.LanguageService, TranslationService | Manage languages and read localized text. |
django_chassis.fields.TranslateField | Store localized model values with per-language controls. |
django_chassis.dto.global_alert.GlobalAlertDTO | Supply notifications from a callable or signal receiver. |
django_chassis.options.PageHeaderOption, FormLayoutOption, FieldHistoryOption | Configure titles, fieldsets and the history comparison. |
django_chassis.options.EntityPickerOption | Enable a permission-aware foreign key autocomplete. |
For the WizardAdminPage and WizardStepDTO contracts, see
multi-step admin pages.
Transfer backend compatibility
Changed in 1.0.23Use 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.
| API | Purpose |
|---|---|
AccountActionService, AccountActionType, AccountAction | Apply audited account transitions. The built-in role and status handlers validate the operator and the requested transition before writing. |
UserAdminAccessService, UserAdminCreationService, UserModelService | Enforce the built-in access rules, create supported user accounts, and resolve the configured model's identifier and personal fields. |
UserProfileService, AdminProfileService, AdminProfileDTO, UserProfileActivityDTO | Collect stored profile, contact and activity data. The Admin profile composes those fields with the current session and recent audited actions. |
UserSessionService, UserSessionEndReason, SessionKeyCryptoService | Register, locate, touch or terminate Chassis-tracked sessions. The crypto service protects the stored session-key value used for revocation. |
LoginAttemptLimitService, LoginAttemptAvailabilityDTO | Evaluate retry availability for an account and client scope, persist attempts and manage the configured attempt cycle. |
AdminAuditLogService, AdminAuditAction, AdminAuditResult, RequestClientMetadataDTO | Capture request metadata and finish an audit record with its outcome. The standard audit middleware manages the lifecycle. |
ClientIpService, ClientDeviceService, ClientDeviceDTO, ClientGeoIpService | Resolve trusted client addresses, identify browser and OS, and look up a country from a local GeoIP database. |
PermissionInitializationService, ActionPermissionValidationService, PermissionNameNormalizationService and PermissionNameLanguage | Initialize and validate declared codes and normalize human-readable permission names. Register project declarations with PermissionRegistry.register(PermissionOption(...)). |
ConfirmedActionService, ConfirmedActionForm | Render the shared confirmation workflow for actions that explicitly opt into that service. A ModelAdmin object action defines its own request handling. |
DeletedObjectsService | Collect 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
| API | Purpose |
|---|---|
ImportFieldDTO, ExportFieldDTO, ExportFilterDTO, ImportExportFieldService, ExportFilterService | Describe fields, resolve filter lookups and enforce the configured allowlists. |
ImportPreviewDTO, ImportPreviewRowDTO, ImportPreviewSkippedRowDTO, ImportApplyService | Validate mappings and rows and report accepted, skipped and invalid input. The apply stage persists the batch. |
ImportExportScopeService, ImportStatus, ExportStatus | Resolve the site and model that own a transfer and represent its persisted state. Legacy import PREVIEW records may remain after an upgrade. |
ImportExportSerializationService | Parse the supported input formats and serialize exported records. Use the normal transfer flow to apply storage, fields and permissions. |
ImportExportProcessService, ImportExportTaskService | Execute 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
SidebarChildOptionrepresents either a model or a custom-page sidebar entry.AdminSidebarItemDTOandAdminSidebarChildItemDTOcarry resolved navigation.AdminNavbarItemDTOandAdminNavbarItemTypeidentify buttons, dropdowns and theme controls.AdminModalDTOcarries the registered modal's trigger details.DashboardChartDTO,DashboardAlertDTO,DashboardMetricDTOandDashboardActionDTOdescribe rendered widgets.DashboardLiveWidgetType,DashboardSourceState,DashboardStackedItemDTOandDashboardStackedItemTonedescribe live payload kinds, source states and stacked data. See dashboard metrics and charts.render_booleanemits the standard Admin boolean representation. UseDisplayStatefor components that present semantic status.DATE_INPUT_FORMAT,TIME_INPUT_FORMAT, andDATETIME_INPUT_FORMATare input formats. Their corresponding*_MASKand*_PLACEHOLDERconstants support the date and time widgets.- See UI components for the complete set of workspace DTOs
that render through the
chassis_componenttemplate tag.