Community contrib extensions for the Django Unfold admin theme
Project description
Django Unfold Contrib
Useful helpers to customize the Django Unfold theme and make it compatible with several other common Django packages.
Table Of Contents
Overview
A collection of useful customization for Django Unfold:
- Improved admin list view tables on mobile
- Fix compatibility with:
- Templates in the Django Unfold style for:
Features
Improved Admin Mobile List Table
Unfold's admin list view converts the model list to a series of cards on mobile, which can be hard to read and navigate. This addon provides a CSS override that keeps the table layout on all screen sizes with horizontal scrolling support.
Before:
After:
To use:
- Include the
unfold_contrib.mobile_tableapp in yourINSTALLED_APPS, before theunfoldapp:INSTALLED_APPS = [ # ... "unfold_contrib.mobile_table", # Must come before unfold "unfold", # ... ]
The app order is important because Django's template loader uses the first matching template it finds. Ifunfold_contrib.mobile_tableis listed afterunfold, the Unfold template will be used instead.
Compatibility Fixes
Django Object Actions
The django-object-actions package allows you to put Django admin actions on the change page of an individual model. Without this compatibility fix object actions are not correctly styled or positioned in the header.
Before:
After:
To use:
- Import and use the
@unfold_actiondecorator on your action functions (noINSTALLED_APPSentry needed):from unfold_contrib.actions import unfold_action class MyModelAdmin(DjangoObjectActions, admin.ModelAdmin): # ... change_actions = ["foobar"] @unfold_action(label="Foo Bar") def foobar(self, request, obj): # ...
Django Select2
The django-select2 package provides a nice multi-select widget. Without this compatibility fix the widget is not styled to match Unfold's dark theme.
Before:
After:
To use:
- Include the
unfold_contrib.select2_darkapp in yourINSTALLED_APPS
Templates
Django Allauth
The django-allauth package provides comprehensive user login and 3rd party login features. Included in Django Unfold Contrib are:
- Base themes for django-allauth which match the Django Unfold styling
- Inclusion of message displays on the login page (to see error messages about login info)
- Google branded login button above normal login form
- Logout view which clears messages
To use:
- Include the
unfold_contrib.allauthapp in yourINSTALLED_APPS - To show the Google Sign-In button on the admin login page, set the following in your
settings.py(it is disabled by default):UNFOLD_CONTRIB_GOOGLE_AUTH_ENABLED = True
- If you want the custom logout view also add the
unfold_contrib.allauth.urlsto yoururls.pyfile (place it after allauth's URLs to override properly):from django.contrib import admin from django.urls import path, include urlpatterns = [ path("admin/", admin.site.urls), path("accounts/", include("allauth.urls")), # required for allauth path("accounts/", include("unfold_contrib.allauth.urls")), # for clean logout ]
Custom Admin Pages
Provides a base template which you can use to make custom Django admin pages in the Unfold styling.
To use:
- Include the
unfold_contrib.custom_admin_pagesapp in yourINSTALLED_APPS - Extend
unfold_contrib/base_admin_page.htmlin your custom admin template, override thecontentblock:{% extends 'unfold_contrib/base_admin_page.html' %} {% block content %} <h1>My Custom Admin Page</h1> <p>This is a custom page that uses the Unfold branding and includes jQuery.</p> {% endblock %}
Developer Setup
Instructions for developers of the Django Unfold Contrib package. See Features for how to use Django Contrib Actions in your own project.
SourceHut Builds
This project uses SourceHut for continuous integration and publishing. The .build.yml file defines the build process.
To give the build job permissions to push to PyPi setup a secret:
- Name:
pypi-django-unfold-contrib - Secret:
[main] username = __token__ password = <TOKEN HERE, UNQUOTED>
In is important the section in the config file be named[main]for Hatch to work properly.
Replace<TOKEN HERE, UNQUOTED>with the PyPi API token (not in quotes) authorized for the django-unfold-contrib package. - Path:
~/.pypirc - Mode:
600
Place the secret UUID in the build config file.
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_contrib-0.1.0rc6.tar.gz.
File metadata
- Download URL: django_unfold_contrib-0.1.0rc6.tar.gz
- Upload date:
- Size: 247.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.3 cpython/3.12.12 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f07bbc7091ed6e6ec4843b4f3af76f6325babb0c074424f429ad3e7f525609e
|
|
| MD5 |
f0048b6a1e7a01631b6a24f5212f6a08
|
|
| BLAKE2b-256 |
01d380db2b3a34352b8eaad6821bc8f079f5445f73042941874eed741efbfb44
|
File details
Details for the file django_unfold_contrib-0.1.0rc6-py3-none-any.whl.
File metadata
- Download URL: django_unfold_contrib-0.1.0rc6-py3-none-any.whl
- Upload date:
- Size: 24.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.3 cpython/3.12.12 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adeb0e0c174b8e93089b26eaedab0b6130dd3a89931aab6b09780b84f2657c31
|
|
| MD5 |
3dc725e150d3bf5d6bc1331019f3d854
|
|
| BLAKE2b-256 |
36969f9d866e2afc76dcacea443607407dd13e00d25fb2271eb1d3d69df820ea
|