Skip to main content

Presentation

Added in 1.0.1

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}})
ParameterTypeDefault
fieldsfield names to badgerequired
colorsfield → value → ButtonColorempty mapping

Pretty JSON

Replaces configured JSON fields with syntax-highlighted read-only output (Pygments).

from django_chassis.options import PrettyJsonOption

PrettyJsonOption(fields=['payload'])

Decimal amounts

Displays 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'])

Date and time widgets

ChassisAdminMixin installs masked widgets for date, time, and datetime fields:

  • DateInput
  • TimeInput
  • DateTimeInput / SplitDateTime

No option is required. The widgets ship with the mixin.

See also