This guide walks you through registering your first Django model with django-var-cms. By the end you will have a fully functional list view, add/edit forms, a read-only detail page, and role-based access control — all without writing a single URL pattern or template. The examples use 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.
Article model from the demo app, which covers the most common field types and permission patterns.
Create myapp/var_cms_admin.py
django-var-cms uses an auto-discovery mechanism identical to Django’s admin. On startup, At a minimum, the file must import That single line is enough to get a working list view, add form, edit form, and detail page. All display and permission options below are additive enhancements.
VarCmsConfig.ready() loops over every entry in INSTALLED_APPS and tries to import <app>.var_cms_admin. If the file exists it is loaded; if it is missing it is silently skipped.Create the file in your app directory:var_cms_site and call .register():myapp/var_cms_admin.py
Make sure
"myapp" is listed in INSTALLED_APPS in your settings.py. The auto-discovery only processes apps that Django knows about.Define a ModelAdmin class
Replace the bare
VarCMSModelAdmin reference with a subclass that describes how the model should appear in the CMS. The Article model below demonstrates the most useful display options:myapp/var_cms_admin.py
Add RolePermission entries
Without a
permissions list, only superusers can access the model. Add RolePermission objects for each Django Group you want to grant access, and optionally a UserPermission for a specific user account:myapp/var_cms_admin.py
Register the model
Call You can register multiple models in a single file:
var_cms_site.register() at the bottom of the file, after the class definition:myapp/var_cms_admin.py
myapp/var_cms_admin.py
Start the server and open the dashboard
dashboard_card = True shows a live record-count card on the home screen.If you haven’t created a superuser yet, run
python manage.py createsuperuser first. The CMS login page is at /var-cms/login/.Complete Working Example
Here is a self-containedvar_cms_admin.py based directly on the demo app, ready to copy into your own project. It registers Article with full role-based permissions, a Quill.js editor, slug validation, and dashboard card buttons:
myapp/var_cms_admin.py
Article model for reference:
myapp/models.py
Next Steps
Role-Based Permissions
Deep dive into
RolePermission, UserPermission, role_editable_fields, and the wildcard "*" fallback role. Learn how permission resolution works at request time.Form Layouts
Customise form column widths with the 12-column grid presets, group fields into visual rows with
form_field_rows, add placeholders and help text, and switch dropdown widgets to searchable or multi-select variants.Media Handling
Enable modal previews for images, video, audio, and PDFs. Use the built-in image cropper and the
/api/media/convert/ endpoint to transform file formats on the fly.VarCMSModelAdmin API
Full reference for every attribute and hook method on
VarCMSModelAdmin: save_model, delete_model, get_queryset, custom_object_actions, dashboard card configuration, and more.