TheDocumentation 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.
var_cms_tags library provides template tags and filters used throughout the django-var-cms admin interface. Load the library in any template before using its tags or filters:
URL Helper Tags
These simple tags resolve the named URL patterns registered by django-var-cms for standard CRUD views, using Django’sreverse() internally. They accept the Django app label and model name as lowercase strings.
var_cms_list_url
Returns the URL for the paginated list view of a model.
var_cms_add_url
Returns the URL for the add / create form of a model.
var_cms_edit_url
Returns the URL for the edit form of a specific object instance.
var_cms_delete_url
Returns the URL for the delete confirmation page of a specific object instance.
var_cms_view_url
Returns the URL for the read-only detail view of a specific object instance.
var_cms_action_url
Returns the URL for a custom object action registered on a VarCMSModelAdmin. The action_name must match the name key of an entry in custom_object_actions.
Field Preview Tag
var_cms_field_preview
Renders an inline HTML preview snippet for an ImageField or FileField on an existing model instance. Returns an empty string if the object is None, the field has no value, or an exception occurs during rendering.
| Field type | Rendered output |
|---|---|
ImageField | <img> tag with class="preview-thumb" and a data-preview attribute pointing to the image URL. Displayed at 48×48 px. |
FileField | A Lucide icon (auto-selected by file extension) followed by an <a> tag with class="file-preview-link", data-ext, and data-url attributes. |
| Extension(s) | Lucide icon |
|---|---|
mp4, webm, mov | video |
mp3, wav, ogg | music |
pdf | file-text |
| (all others) | paperclip |
Filters
safe_html
Marks a string value as safe HTML, bypassing Django’s auto-escaping. Equivalent to calling mark_safe().
get_item
Dictionary lookup filter. Returns dictionary.get(key) or None if the key is absent or the object does not have a get method.
index
List index filter. Returns list[i] or an empty string if the index is out of range or the value is not subscriptable.
query_transform Tag
A context-aware tag that builds a URL-encoded query string by merging the current request’s GET parameters with the provided keyword arguments. Useful for building pagination, filter, and sort links that preserve existing query state.
- Pass a new value for a key to set or override it.
- Pass
Noneas the value for a key to remove it from the query string.
This tag requires the
request object in the template context. Ensure django.template.context_processors.request is included in your TEMPLATES settings.Form Layout Filters
These filters are used internally by django-var-cms form templates to drive the responsive 12-column grid layout. They are powered by attributes set on theVarCMSModelAdmin registration class.
form_field_grid_style
Returns a CSS grid-column: span N; style string for the given bound field. The filter resolves the span using the following priority order:
form_field_widths— explicit override on the admin class. Maps a field’shtml_nameto a width preset string.form_field_rows— if the field is listed in a row group, span is computed as12 ÷ len(row), floored to at least1.- Default heuristic —
CheckboxandTextareawidgets span 12 columns (full width); all other inputs span 6 columns (half width).
form_field_styles for the field, those inline styles are appended to the result.
| Preset | CSS output |
|---|---|
"full" | grid-column: span 12; |
"half" | grid-column: span 6; |
"one-third" | grid-column: span 4; |
"two-thirds" | grid-column: span 8; |
"one-fourth" | grid-column: span 3; |
"three-fourths" | grid-column: span 9; |
field_widget_type
Returns the custom widget type string for a field, looked up from form_field_widgets on the VarCMSModelAdmin class using field.html_name. Returns an empty string if no custom widget is configured for that field.