The list view is the primary browsing interface for any registered model. django-var-cms gives you fine-grained control over which columns appear, how sidebar filters are rendered, how full-text search queries are applied, and how rows are paginated and sorted — all through declarative class attributes on yourDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/rahul-baberwal/django-var-cms/llms.txt
Use this file to discover all available pages before exploring further.
VarCMSModelAdmin subclass.
list_display — Table Columns
list_display is a list of field names (or double-underscore traversal paths) that appear as columns in the list view table. If you leave it empty, django-var-cms automatically uses the first six fields returned by model._meta.get_fields(), skipping any many-to-many or reverse relation fields.
Special field rendering
The list view applies automatic display logic based on the underlying Django field type:ImageField
Rendered as a thumbnail
<img> tag with the CSS class preview-thumb and a data-preview attribute. Thumbnail dimensions default to 38 × 38 px and are controlled by list_image_width and list_image_height.FileField
Rendered as a clickable icon link. The Lucide icon changes by extension:
video for MP4/WebM, music for MP3/WAV, file-text for PDF, and paperclip for all other types.BooleanField
Rendered as a green Lucide
check icon for True and a red Lucide x icon for False.title tooltip attribute.
You can also traverse related model fields using the double-underscore notation:
django.contrib.gis is installed and a field is a GIS geometry type, the list view renders the geometry type name and coordinate count (e.g., Point (1pts)).
list_image_width / list_image_height
Control the pixel size of image thumbnails rendered in list columns. Both default to 38.
list_filter — Sidebar Filters
list_filter is a list of field names for which django-var-cms will render a filter widget in the sidebar. The widget type is determined automatically by the build_filter_widgets() function in registry.py based on the field’s type:
| Field type | Widget rendered |
|---|---|
CharField / IntegerField with .choices | select — dropdown of available choices |
ForeignKey / OneToOneField | select — dropdown of all related objects (up to 300) |
BooleanField | boolean — yes / no / any toggle buttons |
DateField / DateTimeField | date_range — from/to date pickers |
IntegerField / FloatField / DecimalField | number_range — min/max numeric inputs |
| All other field types | text — a plain text input for substring matching |
?status=published&is_featured=1). Multiple filters stack together, narrowing the queryset cumulatively.
search_fields — Full-Text Search
search_fields lists the fields that are searched when the user types a query in the search bar. Each listed field is queried with a case-insensitive __icontains lookup, and results matching any field are returned (OR logic).
"django" would return any article where the title, body, or author contains the string “django” (case-insensitively). The search query is passed as the q query parameter in the URL.
ordering — Default Sort Order
ordering sets the default queryset order when no column sort is active. Use a leading - for descending order, matching Django’s standard order_by() syntax.
list_per_page — Pagination
list_per_page controls how many rows appear on each page of the list view. The default is 25. The paginator uses Django’s built-in Paginator class.
list_select_related — Query Optimisation
When list_display includes fields from related models (via FK traversal), enabling list_select_related adds a select_related() call to the queryset, eliminating N+1 database queries.
Column Sorting
Every column header in the list view is clickable. Clicking a header sorts the list by that field ascending; clicking again toggles to descending. The sort state is tracked with two URL query parameters:| Parameter | Description |
|---|---|
o | The field name to sort by (must be in list_display) |
ot | Sort direction — "asc" (default) or "desc" |
created_at column header twice:
Complete Example
The followingCategoryAdmin, ArticleAdmin, and MediaAssetAdmin classes from the demo app illustrate every list-view option working together:
- CategoryAdmin
- ArticleAdmin
- MediaAssetAdmin
Sorting is only available for fields that are direct model fields — not for computed properties or double-underscore traversals. The list view checks that the
o parameter is present in list_display before applying the order.