Tables
TableOption is the generic table contract. Related entities, information
pages, and history-style views reuse it. Full field tables:
Options catalog.
from django_chassis.enums import ButtonColor, RowActionDisplay
from django_chassis.options import TableActionOption, TableActionUrlKwargOption, TableColumnOption, TableOption
TableOption(
columns=[TableColumnOption(field='title', label='Title'), TableColumnOption(field='status', label='Status')],
fieldset_title='Items',
empty_message='No rows.',
selection_field='id',
actions=[
TableActionOption(
url_name='admin:catalog_book_change',
label='Open',
icon_class='fa-solid fa-arrow-right',
color=ButtonColor.PRIMARY,
display=RowActionDisplay.ICON,
object_field='id',
object_url_kwarg='object_id',
permission='view',
)
],
)
Columns
TableColumnOption.field is a dotted path on the row object. label is the
column header.
Actions
TableActionOption builds a URL from url_name plus kwargs taken from the
row.
| Parameter | Type | Default |
|---|---|---|
url_name | Django URL name | required |
label | localized string | required |
icon_class | Font Awesome class | required |
color | ButtonColor | PRIMARY |
display | ICON or BUTTON | ICON |
object_field | row attribute for the object id | id |
object_url_kwarg | URL kwarg name | object_id |
permission | codename or None | None |
condition_method | method name or None | None |
url_kwargs | extra TableActionUrlKwargOption | [] |
TableActionUrlKwargOption(name=..., value=...) is a constant extra
reverse() kwarg. The per-row object id still comes from object_field.
An unnamespaced url_name is prefixed with the current AdminSite name.
Selection
selection_field— row attribute used as the checkbox valueselection_disabled_field— when truthy, the row cannot be selectedselection_checked_field— when truthy, the row starts checked
Empty state
empty_message is shown when the provider returns no rows.
TableService and PaginationService render and paginate these tables. You
rarely call them directly.