django-var-cms renders every add/edit form on a 12-column CSS grid. You can control the width of each field, group fields into visual rows, enable a rich text editor, enforce regex patterns, swap in custom dropdown widgets, and inject CSS classes, inline styles, placeholders, and help text — all from 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 without touching any template.
12-Column Grid — form_field_widths
The form grid spans 12 columns and automatically stretches to fill the available screen width. Use form_field_widths to set a named width preset for any field.
| Preset | Grid columns | Description |
|---|---|---|
"full" | 12 | Full row width — default for TextField and BooleanField |
"half" | 6 | Half the row — default for most other field types |
"one-third" | 4 | One-third of the row |
"two-thirds" | 8 | Two-thirds of the row |
"one-fourth" | 3 | One-quarter of the row |
"three-fourths" | 9 | Three-quarters of the row |
form_field_widths takes the highest priority in the layout system. A field listed in form_field_widths always uses its explicit preset, regardless of any form_field_rows grouping for that field.
Field Row Grouping — form_field_rows
form_field_rows lets you declare groups of fields that should always appear on the same visual row. Fields within a group automatically share the available 12 columns equally — you don’t need to calculate widths manually.
- A row of 2 fields → each field gets 6 columns (
"half") - A row of 3 fields → each field gets 4 columns (
"one-third") - A row of 4 fields → each field gets 3 columns (
"one-fourth")
form_field_rows is evaluated after form_field_widths. If a field already has an entry in form_field_widths, that explicit preset wins and the row grouping is ignored for that field.
Rich Text Editor — html_fields
Add any TextField name to html_fields to replace the plain <textarea> with a Quill.js rich text editor. The editor is fully embedded — no external CDN or additional configuration is required. Non-html TextField fields receive a plain <textarea> with rows=4.
TextField would store its value.
Regex Validators — regex_validators
regex_validators maps a field name to a (pattern, message) tuple. django-var-cms applies the validation both client-side (HTML5 pattern and title attributes on the input widget) and server-side (a Django RegexValidator attached to the form field), ensuring consistent enforcement regardless of whether JavaScript is enabled.
Custom Dropdown Widgets — form_field_widgets
form_field_widgets maps a field name to a widget type string, giving you control over how ForeignKey, CharField with choices, and ManyToManyField fields are rendered in the form.
| Widget type | Rendered as | CSS classes applied |
|---|---|---|
"select" | Standard <select> dropdown | (no override — Django default) |
"select_search" | Searchable <select> with live filter | vcms-searchable-select |
"multiselect" | CheckboxSelectMultiple (all choices visible) | vcms-checkbox-multi |
"multiselect_search" | CheckboxSelectMultiple with a search input | vcms-checkbox-multi vcms-checkbox-search |
"multiselect" and "multiselect_search" use CheckboxSelectMultiple and are designed for ManyToManyField relationships. Use "select_search" for ForeignKey fields instead.Widget CSS Classes — form_widget_classes
form_widget_classes injects CSS class names directly onto the underlying <input>, <select>, or <textarea> HTML element. The classes are appended to any existing class attributes already on the widget.
Placeholders — form_field_placeholders
form_field_placeholders sets the HTML placeholder attribute on each input widget, giving users contextual guidance before they type.
Help Text — form_field_help_texts
form_field_help_texts sets the help_text property on each form field, overriding any help_text defined on the model field itself.
Readonly Fields and Disabled Fields
Fields listed inreadonly_fields are excluded from the form entirely and displayed separately as static values. They cannot be edited by any user.
Per-role edit control is handled through role_editable_fields. When a user’s role restricts editable fields to a subset, any form field not in that subset has field.disabled = True applied — the field remains visible in the form but cannot be changed.
Container Classes and Styles
Two additional dicts apply to the wrapper<div> that surrounds each field (rather than the input element itself).
form_field_classes
Injects CSS class names onto the field’s container <div>:
form_field_styles
Appends inline CSS style rules to the field’s container <div>. These are merged with the grid-column span rule that the 12-column system injects:
Complete Example
The example below combines all form layout features into a realisticArticleAdmin: