A modern, role-based Django CMS registry with rich media previews
Project description
django-var-cms
A modern, highly customizable administrative Control Panel and CMS registry for Django projects. Built with premium glassmorphic aesthetics, role-based security, and rich media processing.
Created by Rahul Baberwal.
๐ Key Features
- ๐จ Modern Design System: Responsive glassmorphic layout, collapsible navigation sidebar with
localStoragepersistent state, and custom HSL accent color configurations. - ๐ Role & User Permissions: Manage fine-grained view, list, edit, add, and delete actions matching Django Groups or specific user accounts.
- ๐ HTML Editor: Integrated Quill.js rich text editor out of the box.
- โ Regex Field Validation: Easily enforce custom regular expression patterns both client-side and server-side.
- ๐ผ๏ธ Media Previews & Image Cropper:
- Modal-based previews for images, video, audio, and PDFs.
- Built-in Image Cropper (rotate, flip, custom aspect ratio crops).
- API endpoints for media conversion (JPEG, PNG, WebP, WAV, MP3, MP4).
โ๏ธ Setup & Installation
1. Install Dependencies
Install django-var-cms along with required media dependencies:
# Using pip
pip install django-var-cms pillow whitenoise
# Using uv
uv add django-var-cms pillow whitenoise
2. Configure settings.py
Register "var_cms" in your Django INSTALLED_APPS and specify static/media paths:
# settings.py
INSTALLED_APPS = [
# ... Django standard apps
"var_cms",
# "demo", (optional demo app)
]
# Media settings for handling file uploads/crops
MEDIA_URL = "/media/"
MEDIA_ROOT = BASE_DIR / "media"
# Static files settings
STATIC_URL = "/static/"
STATICFILES_DIRS = [BASE_DIR / "static"]
STATIC_ROOT = BASE_DIR / "staticfiles"
# Redirect paths for authentication
LOGIN_URL = "/var-cms/login/"
LOGIN_REDIRECT_URL = "/var-cms/"
3. Add URL Routing
Include the var_cms routes in your project's main urls.py:
# urls.py
from django.urls import path, include
urlpatterns = [
# ... other paths
path("var-cms/", include("var_cms.urls", namespace="var_cms")),
]
๐งช Seeding the Demo App (Optional)
If you are developing or exploring features in the source repository:
- Run migrations to initialize the database:
python manage.py migrate
- Run the seed management command to generate default database models, pages, media, and test accounts:
python manage.py seed_demo
- Start the server:
python manage.py runserver
- Access the dashboard at
http://127.0.0.1:8000/var-cms/.
Demo User Accounts
| Username | Password | Role / Group | Permissions |
|---|---|---|---|
| admin | admin | superuser | Full unrestricted access |
| editor | editor | editor | Add + Edit (Cannot delete) |
| author | author | author | Add + Edit specific fields (Cannot delete) |
| viewer | viewer | viewer | List + View records only |
| alice | alice | viewer | Viewer permissions, with delete override |
๐ ๏ธ Registering Models (Example)
Create a file named var_cms_admin.py in any of your Django apps. It is automatically discovered on startup.
# myapp/var_cms_admin.py
from var_cms.registry import var_cms_site, VarCMSModelAdmin
from var_cms.permissions import RolePermission, UserPermission
from .models import Article
# Customize branding globally
var_cms_site.site_header = "My CMS"
var_cms_site.site_sub = "Control Center"
var_cms_site.site_url = "https://example.com"
var_cms_site.logo_url = "/static/var_cms/var.png" # Custom brand logo
class ArticleAdmin(VarCMSModelAdmin):
list_display = ["title", "category", "author", "status", "created_at"]
list_filter = ["status", "category"]
search_fields = ["title", "body", "author"]
readonly_fields = ["created_at", "updated_at", "view_count"]
# Enable Quill.js Rich Text Editor on body field
html_fields = ["body"]
# Custom icon from Lucide
icon = "file-text"
# Regex validator: client-side + server-side validation
regex_validators = {
"slug": (r"^[a-z0-9-]+$", "Slug must consist of lowercase letters, numbers, and hyphens only.")
}
# Define role permissions
permissions = [
RolePermission("superuser", add=True, list=True, view=True, edit=True, delete=True),
RolePermission("editor", add=True, list=True, view=True, edit=True, delete=False),
RolePermission("author", add=True, list=True, view=True, edit=True, delete=False),
RolePermission("viewer", add=False, list=True, view=True, edit=False, delete=False),
UserPermission("alice", add=True, list=True, view=True, edit=True, delete=True),
]
# Limit editable fields by user role
role_editable_fields = {
"superuser": "__all__",
"editor": ["title", "slug", "body", "status", "category"],
"author": ["title", "body", "status"],
"*": [],
}
# Register the model on the custom site
var_cms_site.register(Article, ArticleAdmin)
๐จ Layout Customizations
You can customize the accent color scheme using HSL values on the global var_cms_site registry:
# Custom accent color (Emerald green)
var_cms_site.accent_color = "142, 72%, 45%"
๐ URL Structure
/var-cms/ โ Admin Dashboard
/var-cms/{app}/{model}/ โ Paginated List view
/var-cms/{app}/{model}/add/ โ Object Creation Form
/var-cms/{app}/{model}/{pk}/ โ Object Modification Form
/var-cms/{app}/{model}/{pk}/view/ โ Read-only Details view
/var-cms/{app}/{model}/{pk}/delete/โ Object Delete confirmation
/var-cms/api/media/crop/ โ POST endpoint: crop image
/var-cms/api/media/convert/ โ POST endpoint: convert media file type
๐ Detailed Integration & How To Use Guide
For detailed reference on branding customizations, optional two-factor authentication (OTP), and role-based permissions, see below:
๐จ Branding & Customization Settings
You can customize the header, subtitle, favicon, and email verification options on the global registry singleton.
Inside your var_cms_admin.py or startup setup, modify the settings on the singleton instance var_cms_site:
from var_cms.registry import var_cms_site
# โโ Change Name & Subtitle โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
var_cms_site.site_header = "CMS" # Default: "VAR CMS"
var_cms_site.site_sub = "DASHBOARD" # Default: "CONTROL PANEL"
# โโ Customize "View Site" Link โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
var_cms_site.site_url = "https://myblog.com" # Default: "/"
# โโ Custom Image Logo & Favicon โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
var_cms_site.logo_url = "/static/var_cms/var.png" # Serves var.png as the brand logo & tab favicon
# โโ Optional OTP 2FA Verification โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
var_cms_site.enable_otp = True # Requires SMTP settings. Sends 6-digit OTP code to email.
๐ Authentication & Password Tools
1. Custom Glassmorphic Login
- A premium, modern dark login interface is provided out-of-the-box at
/var-cms/login/.
2. Optional OTP Verification (2FA)
- When
enable_otp = True, successful user logins redirect to an OTP verification view. - The system sends a 6-digit code to the user's email.
- Development Tip: If SMTP parameters are not configured in
settings.py, the code prints directly to your terminal console as[VAR CMS OTP]: ******to prevent developers from getting locked out.
3. Forgot Password Request
- Includes a "Forgot Password" link on the login screen. It prompts users to enter their email or username, generates a password reset OTP, and allows defining a new password securely.
4. Logged-in Password Reset
- Users can change their password directly inside the dashboard. Click the User profile badge -> select Reset Password. It renders a custom password modification form embedded within the base CMS template.
๐ฅ Credits & Authors
Created and maintained by Rahul Baberwal โ rahulbaberwal.com.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_var_cms-1.0.4.tar.gz.
File metadata
- Download URL: django_var_cms-1.0.4.tar.gz
- Upload date:
- Size: 747.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
660bc48319ada30866132d8a66eca7916820893a79521dd791abc59c98c293dc
|
|
| MD5 |
2dfbb00280accca687c94931392e283f
|
|
| BLAKE2b-256 |
a1c1a348f9674beea09f66e05d07cb10dc6d09636abdee6c9dc8886ec4937c45
|
File details
Details for the file django_var_cms-1.0.4-py3-none-any.whl.
File metadata
- Download URL: django_var_cms-1.0.4-py3-none-any.whl
- Upload date:
- Size: 759.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74c0486b055c76b90cde0e0452c514a1940ad61d3a84e27be9c15583154ea30f
|
|
| MD5 |
652fd15992f6a202377621bc5d519760
|
|
| BLAKE2b-256 |
4b08297630ed4a3a1cf2aa4e199795108538af449bbe0633b5bb09860c731ca4
|