Unofficial extra for Django Unfold Admin. Supports django-parler and django-cms.
Project description
Django Unfold Extra
Unofficial extension for Django Unfold Admin. Adds support for django-parler and django-cms to the modern and clean Django Unfold admin interface.
Overview
Django Unfold Extra enhances the beautiful Django Unfold admin interface (v0.77.1) with additional functionality for:
- django-cms: Integration with Django CMS 5.0 - Uses unfold admin colors for django cms
- django-parler: Multilingual support for your Django models
- versatile-image: Improved integration with django-versatileimagefield, including preview and ppoi
- Unfold auto-update: Styles can be automatically updaten from official unfold package via npm
- Theme-Sync: Use either Unfold or Django CMS switcher to control themes. You can run both at the same time, with or without both controls enabled.
This package maintains the clean, modern aesthetic of Django Unfold while adding specialized interfaces for these popular Django packages.
It uses unobtrusive template and CSS-styling overrides where possible. As Django CMS uses many '!important' flags, pagetree.css had to be rebuilt from sources to remove some conflicting style definitions.
Note: Django CMS support is not fully tested, but all features should work, beside filer.
Installation
-
Install the package via pip:
pip install django-unfold-extra
-
Add to your INSTALLED_APPS in settings.py:
INSTALLED_APPS = [
# Unfold theme
'unfold',
'unfold_extra',
'unfold_extra.contrib.cms', # if extra packages
'unfold_extra.contrib.parler',
'unfold_extra.contrib.auth' # you likely want to use your own implementation
'unfold_extra.contrib.sites'
# Your apps
# ...
]
Make sure you've set up Django Unfold according to its documentation. https://github.com/unfoldadmin/django-unfold
Add the following to your settings.py:
from django.templatetags.static import static
UNFOLD = {
"STYLES": [
lambda request: static("unfold_extra/css/styles.css"), # additional styles for 3rd party packages
],
"SCRIPTS": [
lambda request: static("unfold_extra/js/theme-sync.js"), # switch django cms theme from "Unfold Admin"
],
}
CMS_COLOR_SCHEME_TOGGLE = False # disable django cms theme switch -> use Unfold admin theme switch or disable Unfold theme switch via styles, no config option yet.
Add {% unfold_extra_styles %} and {% unfold_extra_theme_receiver %} from unfold_extra_tags to your base HTML template.
- Enables unfold admin colors in django cms
- theme switch from unfold admin to change theme in djangs cms (light/dark/auto)
{% load static cms_tags sekizai_tags unfold_extra_tags%}
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}{% endblock title %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% render_block "css" %}
{% unfold_extra_styles %}
{% unfold_extra_theme_sync %}
...
</head>
...
</html>
Usage
django-parler Support
- UnfoldTranslatableAdminMixin
- UnfoldTranslatableStackedAdminMixin
- UnfoldTranslatableTabularAdminMixin
- TranslatableStackedInline, TranslatableTabularInline
Example use:
class TranslatableAdmin(UnfoldTranslatableAdminMixin, BaseTranslatableAdmin):
"""custom translatable admin implementation"""
# ... your code
class MyInlineAdmin(TranslatableStackedInline):
model = MyModel
tab = True # Unfold inline settings
extra = 0 # django inline settings
django-cms Support
- Theme integration in django admin (partial support in frontend)
- Pagetree
- PageUser, PageUserGroup, GlobalPagePermission
- Versioning
- Modal support
- Not supported: Filer
Support is automatically applied. Currently, it does not support customization besides compiling your own unfold_extra styles.
Frontend django CMS support
Add unfold_extra_tags to your base HTML template to after loading all CSS styles.
This adds additional styles to integrate django CMS with Unfold Admin and includes "COLORS" from unfold settings to
the public website for authenticated django-cms admin users.
{% load cms_tags sekizai_tags unfold_extra_tags%}
<head>
...
{% render_block "css" %}
{% unfold_extra_styles %}
...
</head>
Custom compilation via npm/pnpm (see src/package.json)
{
"name": "django-unfold-extra",
"description": "Enhancing Django Unfold to support additional packages",
"scripts": {
"update:unfold-deps": "curl -s https://raw.githubusercontent.com/unfoldadmin/django-unfold/main/package.json | jq -r '[\"tailwindcss@\" + .dependencies.tailwindcss, \"@tailwindcss/typography@\" + .devDependencies[\"@tailwindcss/typography\"]] | join(\" \")' | xargs npm install --save-dev",
"update:unfold-css": "curl -o css/styles.css https://raw.githubusercontent.com/unfoldadmin/django-unfold/main/src/unfold/styles.css",
"update:unfold": "npm run update:unfold-deps && npm run update:unfold-css",
"tailwind:build": "npx @tailwindcss/cli -i css/unfold_extra.css -o ../static/unfold_extra/css/styles.css --minify",
"tailwind:watch": "npx @tailwindcss/cli -i css/unfold_extra.css -o ../static/unfold_extra/css/styles.css --watch --minify"
},
"devDependencies": {
"@tailwindcss/cli": "^4.1.7",
"@tailwindcss/typography": "^0.5.19",
"tailwindcss": "^4.1.13"
}
}
Change colors for Django CMS
You can change the colors for django CMS by editing css/unfold_extra.css or just update the unfold colors via settings.py.
- Fetch the latest Unfold version using
update:unfold-depsandupdate:unfold-css - Update config
update:unfold - Add changes
tailwind:watchand `tailwind:build
html:root {
--dca-light-mode: 1;
--dca-dark-mode: 0;
--dca-white: theme('colors.white');
--dca-black: theme('colors.black');
--dca-shadow: theme('colors.base.950');
--dca-primary: theme('colors.primary.600');
--dca-gray: theme('colors.base.500');
--dca-gray-lightest: theme('colors.base.100');
--dca-gray-lighter: theme('colors.base.200');
--dca-gray-light: theme('colors.base.400');
--dca-gray-darker: theme('colors.base.700');
--dca-gray-darkest: theme('colors.base.800');
--dca-gray-super-lightest: theme('colors.base.50');
--active-brightness: 0.9;
--focus-brightness: 0.95;
}
html.dark {
--dca-light-mode: 0;
--dca-dark-mode: 1;
--dca-white: theme('colors.base.900');
--dca-black: theme('colors.white');
--dca-primary: theme('colors.primary.500');
--dca-gray: theme('colors.base.300') !important;
--dca-gray-lightest: theme('colors.base.700');
--dca-gray-lighter: theme('colors.base.600');
--dca-gray-light: theme('colors.base.400');
--dca-gray-darker: theme('colors.base.200');
--dca-gray-darkest: theme('colors.base.100');
--dca-gray-super-lightest: theme('colors.base.800');
--active-brightness: 2;
--focus-brightness: 1.5;
}
Versatile Image Support
- Improved unfold integration via CSS only.
Django Auth, Sites
- Add Unfolds standard settings to
django.contrib.auth,django.contrib.sites.
This is for personal use. You likely want to customize this.
Project details
Release history Release notifications | RSS feed
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_unfold_extra-0.1.12.tar.gz.
File metadata
- Download URL: django_unfold_extra-0.1.12.tar.gz
- Upload date:
- Size: 320.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1aef0c7cb28e24857728b6670c376df054036eb0c3f703ddc40ee7fcd203baf6
|
|
| MD5 |
c9f223046d05141bcb739ca173b72571
|
|
| BLAKE2b-256 |
e1882d3374d68220541048478dc5b4d5e498c6be3f8fdbacbd828e5cdabc6b79
|
File details
Details for the file django_unfold_extra-0.1.12-py3-none-any.whl.
File metadata
- Download URL: django_unfold_extra-0.1.12-py3-none-any.whl
- Upload date:
- Size: 334.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a9b512a9f685dfa85b52e5b472e98346f8c9d6b5b6f01ec4492d7f3d4004b6b
|
|
| MD5 |
7698b35d0b571f51c31f1b539c374540
|
|
| BLAKE2b-256 |
d1309444561e9a03394702ec1199bc990bbafc618e30d0cecb67018fc7f274ca
|