Documentation 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.
VarCMSSite is the central registry that maps Django models to their admin configurations, resolves URL patterns, and carries all branding and dashboard settings. You never instantiate it yourself — a single global instance named var_cms_site is created at module import time and is the object you import throughout your project.
var_cms_site is auto-configured from VAR_CMS_* keys in your settings.py. You can also override any attribute directly in your var_cms_admin.py file after the import, which is the recommended place for per-project branding.URL Mounting
Include the CMS URL patterns in your project’surls.py once:
Registry Attribute
Internal mapping from model class to its
VarCMSModelAdmin instance. Populated by register() and cleared by unregister(). Use get_model_admin() to look up entries rather than accessing this dict directly.Branding Attributes
All branding attributes read their defaults fromVAR_CMS_* keys in settings.py and can be overridden in var_cms_admin.py.
The primary brand title displayed in the top-left of the sidebar and on the login page.
Subtitle rendered below
site_header in the sidebar header area.The URL used by the “View Site” link in the sidebar.
Path or URL of the logo image. Used when
logo_svg is None.Raw inline SVG markup for the logo. When set, this takes precedence over
logo_url. Useful for dynamically colored vector logos.HSL accent color string in the format
"H, S%, L%". Controls the theme highlight color used across buttons, active states, and decorative elements.The lightness value is automatically clamped between 45 % and 85 % to ensure legibility on both light and dark backgrounds.When
True, a successful username/password login redirects to an OTP verification step. A 6-digit code is emailed to the user. If SMTP is not configured, the code is printed to the terminal console as [VAR CMS OTP]: xxxxxx.Heading text displayed at the top of the dashboard page.
Welcome paragraph shown below the dashboard title. Supports
{username} and {user} placeholders which are resolved to the logged-in user’s username at render time.Developer Profile Attributes
These attributes populate the Help & Support page accessible from the sidebar. All read fromVAR_CMS_DEVELOPER_* settings keys and ship with Rahul Baberwal’s contact details as built-in defaults.
Display name of the developer or agency that built the CMS integration.
Developer or agency website URL.
GitHub profile or repository URL.
LinkedIn profile URL.
Contact email address.
URL of the developer’s avatar or profile photo.
Dashboard Visibility Attributes
Model names or
"app_label.model_name" strings whose dashboard cards are hidden regardless of the dashboard_card attribute on the model admin class.When non-empty, only the listed model names or
"app_label.model_name" strings are shown as dashboard cards. All others are hidden. Takes precedence over dashboard_card = True on individual admin classes.hidden_dashboard_cards is evaluated after shown_dashboard_cards. A model in both lists will be hidden.Override the field name used to look up a user’s username for
UserPermission matching. When None, the value is inferred from User.USERNAME_FIELD (which defaults to "username" for Django’s built-in User model).Methods
register(model, admin_class=None, **options)
Register a Django model with the CMS.
| Parameter | Type | Description |
|---|---|---|
model | Type[Model] | The Django model class to register. |
admin_class | Type[VarCMSModelAdmin] | None | The admin class. Defaults to bare VarCMSModelAdmin. |
**options | Any | Keyword arguments are applied as class attributes on a dynamically created subclass of admin_class. |
unregister(model)
Remove a previously registered model from the CMS registry.
get_model_admin(app_label, model_name) → Optional[VarCMSModelAdmin]
Look up the VarCMSModelAdmin instance for a given model by its app label and model name (both lowercase).
None if the model is not registered.
get_urls() → List[URLPattern]
Returns the complete list of URL patterns powering all CMS views: dashboard, login/logout, per-model list/add/edit/delete/view/action routes, and the media API endpoints. Called internally by var_cms/urls.py — you do not normally call this yourself.
_get_username_field() → str
Returns the field name used to identify a user’s username for UserPermission matching. If self.username_field is set, that value is returned directly. Otherwise it reads User.USERNAME_FIELD from the active auth user model (falling back to "username").
Complete Branding Example
Settings Reference
AllVAR_CMS_* settings and their corresponding var_cms_site attribute names:
settings.py key | var_cms_site attribute | Default |
|---|---|---|
VAR_CMS_SITE_HEADER | site_header | "VAR CMS" |
VAR_CMS_SITE_SUB | site_sub | "CONTROL PANEL" |
VAR_CMS_SITE_URL | site_url | "/" |
VAR_CMS_LOGO_URL | logo_url | "/static/var_cms/var.png" |
VAR_CMS_LOGO_SVG | logo_svg | None |
VAR_CMS_ACCENT_COLOR | accent_color | None |
VAR_CMS_ENABLE_OTP | enable_otp | False |
VAR_CMS_DASHBOARD_TITLE | dashboard_title | "Command Hub" |
VAR_CMS_DASHBOARD_TEXT | dashboard_text | (see above) |
VAR_CMS_DEVELOPER_NAME | developer_name | "Rahul Baberwal" |
VAR_CMS_DEVELOPER_WEBSITE | developer_website | "https://rahulbaberwal.com" |
VAR_CMS_DEVELOPER_GITHUB | developer_github | "https://github.com/rahul-baberwal" |
VAR_CMS_DEVELOPER_LINKEDIN | developer_linkedin | "https://linkedin.com/in/rahul-baberwal" |
VAR_CMS_DEVELOPER_EMAIL | developer_email | "im@rahulbaberwal.com" |
VAR_CMS_DEVELOPER_IMAGE | developer_image | "https://github.com/rahul-baberwal.png" |
VAR_CMS_USERNAME_FIELD | username_field | None |
VAR_CMS_HIDDEN_DASHBOARD_CARDS | hidden_dashboard_cards | [] |
VAR_CMS_SHOWN_DASHBOARD_CARDS | shown_dashboard_cards | [] |