Skip to main content

Getting started

The Table (list) view of an admin model can be highly customized using sbadmin_list_display. It builds on top of Django’s standard admin list view, while adding advanced formatting, styling, and control over how data is presented. This allows you to display custom fields or apply formatting to existing fields—without modifying the underlying model.

Key features:

  • Rename columns
  • Format values using Python functions (python_formatter)
  • Include related model data
  • Add badges, colors, or custom HTML
  • Exporting table to XLSX format
  • Advanced filtering
  • Saving filtered views
  • Performing bulk actions

SBAdminField Parameters

ParameterTypeDescription
namestrRequired. Field identifier — can reference a model field or an admin method
titlestrColumn header label
annotateExpressionDjango ORM expression (F, Concat, Case, etc.)
annotate_functioncallable(field, values) -> Expression — dynamic annotation that receives the field instance and current queryset values. Use when the annotation depends on runtime context. Falls back to Value(None) if the function returns None
supporting_annotatesdictAdditional annotations passed to admin method
filter_fieldstrField name for filtering (if different from display)
filter_widgetFilterWidgetCustom filter widget
filter_disabledboolDisable filtering for this field
python_formattercallableFormat value: (obj_id, value) -> formatted_value
list_visibleboolShow/hide column in list (default: True)
list_collapsedboolIf True, the column is pinned/collapsed by default in the column selector (default: False)
tabulator_editorstrTabulator editor type for inline editing (e.g., "input")
tabulator_optionsTabulatorFieldOptionsAdvanced Tabulator column options
xlsx_optionsXLSXFieldOptionsExcel export options for the field

💡Example: Defining the Table / List View

To customize the list view, you define sbadmin_list_display with selected fields in your admin class:

catalog/sb_admin.py
@admin.register(Product, site=sb_admin_site)
class ProductSBAdmin(SBAdmin):
model = Product
inlines = [ProductImageInline]
sbadmin_list_display = (
"name",
"sku",
SBAdminField(name="price", title=_("Price")),
SBAdminField(name="is_active", title=_("Active")),
"manufacturer",
)
list_per_page = 25 # Sets the number of items to display per page