Presentation
These options change how fields look on changelist and change form. They do
not add routes. The mixin generates display methods at __init__ and
rewrites matching names in list_display.
Full field tables: Options catalog.
Badge fields
from django_chassis.enums import ButtonColor
from django_chassis.options import BadgeFieldsOption
BadgeFieldsOption(fields=['status'], colors={'status': {'active': ButtonColor.SUCCESS, 'draft': ButtonColor.SECONDARY}})
| Parameter | Type | Default |
|---|---|---|
fields | field names to badge | required |
colors | field → value → ButtonColor | empty mapping |
Copyable fields
Added in 1.0.7CopyableFieldsOption replaces matching names in list_display, fields,
and fieldsets with a read-only input and an attached Font Awesome clipboard
button. The generated display preserves the source label and ordering.
from django_chassis.options import CopyableFieldsOption
CopyableFieldsOption(fields=['address', 'external_id'])
Field names must be unique. Chassis escapes the rendered value and provides a Clipboard API fallback for non-secure contexts.
Pretty JSON
Replaces configured JSON fields with syntax-highlighted read-only output (Pygments).
from django_chassis.options import PrettyJsonOption
PrettyJsonOption(fields=['payload'])
Decimal amounts
Changed in 1.0.7Displays integer minor-unit fields using two methods on the model:
_get_fraction_number and convert_amount_to_decimal. If either is
missing, the option is ignored. Listed names must be IntegerField or
construction raises ImproperlyConfigured. Duplicate names raise
ValueError. Use this when money is stored as an integer.
from django_chassis.options import DecimalAmountOption
DecimalAmountOption(fields=['amount'])
When the model also implements
convert_amount_field_to_decimal(field_name=..., amount=...), Chassis prefers
that method. This supports models whose amount fields use different currency or
asset contexts while retaining convert_amount_to_decimal(amount=...) as the
fallback contract.
Related fields
Added in 1.0.8 Changed in 1.0.9RelatedFieldsOption exposes a model attribute or a Django relation path as a
read-only changelist column and/or change-form field. Each nested
RelatedFieldOption provides the string path, a localized label, and optional
localized help text. Help text is shown through a small Font Awesome
circled-question icon after the label. The tooltip opens immediately when the
whole label is hovered and remains keyboard-accessible from the icon.
from django.utils.translation import gettext_lazy as _
from django_chassis.options import RelatedFieldOption, RelatedFieldsOption
RelatedFieldsOption(fields=[
RelatedFieldOption(
field='account__owner__email',
label=_('Owner email'),
help_text=_('Email of the owner related through the account.'),
empty_value_display=_('Not assigned')
),
])
Put the exact same path in list_display and/or fieldsets. Chassis validates
it, adds it to readonly_fields, and automatically applies select_related
or prefetch_related. Reverse collections render all values rather than an
arbitrary first row.
empty_value_display overrides the ModelAdmin placeholder for this field.
When the same source path is copyable, its configured label and tooltip are
retained.
Read-only trees
Added in 1.0.9Use AdminTreeDTO, AdminTreeNodeDTO, and render_admin_tree() for escaped,
read-only hierarchies in ModelAdmin display methods or custom pages. Nodes may
contain nested children, a Font Awesome icon_class, and a small badge.
from django_chassis.dto import AdminTreeDTO, AdminTreeNodeDTO
from django_chassis.renderers import render_admin_tree
tree = AdminTreeDTO(
label=_('Assigned permissions'),
empty_text=_('No permissions.'),
nodes=[
AdminTreeNodeDTO(
label=_('Catalog'),
icon_class='fa-solid fa-layer-group',
badge='2',
children=[AdminTreeNodeDTO(label=_('View books'))]
)
]
)
html = render_admin_tree(tree=tree)
Date and time widgets
ChassisAdminMixin installs masked widgets for date, time, and datetime fields:
DateInputTimeInputDateTimeInput/SplitDateTime
No option is required. The widgets ship with the mixin.
Fieldset description alerts
Added in 1.0.7Set Django's standard description and an optional typed alert style on a
fieldset. Chassis escapes the description and renders it as an alert; the
default style is DashboardAlertStyle.INFO.
from django_chassis.enums import DashboardAlertStyle
fieldsets = [
(
'Danger zone',
{
'fields': ['status'],
'description': 'Changing this field takes effect immediately.',
'description_alert_style': DashboardAlertStyle.WARNING
}
)
]