Skip to content

Tables

table_mixins

EnhancedBoundRow

Bases: BoundRow

Extended BoundRow that supports rendering extra rows below the main row.

EnhancedBoundRows

Bases: BoundRows

Extended BoundRows that yields EnhancedBoundRow instances with new-row support.

__getitem__(key)

Slicing returns a new ~.BoundRows instance, indexing returns a single ~.BoundRow instance.

EnhancedTable(*args, extra_data={}, fields=None, **kwargs)

Bases: Table

Extended django-tables2 Table with support for extra rows, dynamic field selection, and extra footers.

Uses the django_reusable/tables/enhanced-table.html template. Columns with a new_row_index attribute are rendered as additional rows beneath the main row.

Parameters:

Name Type Description Default
extra_data

Optional dict of extra context data available to columns/templates.

{}
fields

Optional list of field names to display. All other columns are excluded.

None

get_extra_footers()

Return extra footer rows for the table. Override in subclasses.

Returns:

Type Description

list[dict]: List of dicts with column names as keys for each footer row.

columns

EnhancedColumn(new_row_index=None, colspan=None, no_empty_cell=False, *args, **kwargs)

Bases: Column

Extended django-tables2 Column with support for multi-row rendering and colspan.

Parameters:

Name Type Description Default
new_row_index int

If set to a positive int, this column's value is rendered in an additional row below the main row at the given index.

None
colspan int

Optional HTML colspan attribute for the <td> element.

None
no_empty_cell bool

If True, skip rendering this cell when the value is empty.

False

TextFieldColumn(new_row_index=None, colspan=None, no_empty_cell=False, *args, **kwargs)

Bases: EnhancedColumn

Column that renders as a <textarea> form input.

EnhancedCheckBoxColumn(header=None, attrs=None, checked=None, bound_column=None, **extra)

Bases: CheckBoxColumn

Checkbox column with select-all header toggle and POST-state preservation.

Parameters:

Name Type Description Default
header

Optional custom header text.

None
attrs

HTML attribute dict.

None
checked

Callable to determine checked state. Defaults to reading from POST data.

None
bound_column

Column name used to read selected IDs from POST.

None

RadioButtonColumn

Bases: CheckBoxColumn

Column that renders as a radio button input (single selection per column).

ChoiceColumn(choices, widget=forms.Select, css_class='form-control', *args, **kwargs)

Bases: EnhancedColumn

Column that renders as a <select> dropdown.

Parameters:

Name Type Description Default
choices

Iterable of (value, label) tuples for the select options.

required
widget

Form widget class to use. Defaults to forms.Select.

Select
css_class

CSS class for the widget. Defaults to 'form-control'.

'form-control'

CounterColumn(start=0, *args, **kwargs)

Bases: EnhancedColumn

Column that renders an auto-incrementing row counter.

Parameters:

Name Type Description Default
start

Starting number for the counter. Defaults to 0.

0

NumberColumn(*args, **kwargs)

Bases: EnhancedColumn

Column with right-aligned text styling for numeric values.

CurrencyColumn(human_format=False, *args, **kwargs)

Bases: NumberColumn

Right-aligned column that formats values as currency.

Parameters:

Name Type Description Default
human_format

If True, use abbreviated format (e.g. $1.5M). Defaults to False (standard $1,500,000.00 format).

False

HiddenIdInputColumn(new_row_index=None, colspan=None, no_empty_cell=False, *args, **kwargs)

Bases: EnhancedColumn

Column that renders a read-only hidden input containing the row's ID value.