Use dropdowns in Django admin list filter
Project description
django-unfold-admin-list-filter-dropdown
[!NOTE]
This version is compatible with django-unfold.
A Django admin filter implementation that renders as a dropdown.
If you have more than ten values for a field that you want to filter by in Django admin, the filtering sidebar gets long, cluttered and hard to use.
This app contains the DropdownFilter
class that renders as a drop-down in the
filtering sidebar to avoid this problem.
Usage
Install:
pip install django-unfold-admin-list-filter-dropdown
Enable in settings.py
:
INSTALLED_APPS = (
...
'django_unfold_admin_listfilter_dropdown',
...
)
Use in admin.py
:
from django_admin_listfilter_dropdown.filters import DropdownFilter, RelatedDropdownFilter, ChoiceDropdownFilter
class EntityAdmin(admin.ModelAdmin):
...
list_filter = (
# for ordinary fields
('a_charfield', DropdownFilter),
# for choice fields
('a_choicefield', ChoiceDropdownFilter),
# for related fields
('a_foreignkey_field', RelatedDropdownFilter),
)
Example of a custom filter that uses the provided template:
class CustomFilter(SimpleListFilter):
template = 'django_unfold_admin_listfilter_dropdown/dropdown_filter.html'
def lookups(self, request, model_admin):
...
def queryset(self, request, queryset):
...
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
File details
Details for the file django_unfold_admin_list_filter_dropdown-1.0.10.tar.gz
.
File metadata
- Download URL: django_unfold_admin_list_filter_dropdown-1.0.10.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | db2b8a2446716e234a2e16d35ca3b77820632498626eeca29037dc7c1d8cfc02 |
|
MD5 | 85b5acdef62560532b11e22291f1a13c |
|
BLAKE2b-256 | 5d6f5de6a2af9948a8d21f4d6b054a824d173d14e8e25726d9151613bbcefb6b |
Provenance
File details
Details for the file django_unfold_admin_list_filter_dropdown-1.0.10-py3-none-any.whl
.
File metadata
- Download URL: django_unfold_admin_list_filter_dropdown-1.0.10-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2eb5f952e4686f59a04158dc6c36a9cd7c6c98295149d5b9b6473cb562ec94cf |
|
MD5 | 1edbae22745776d7fceeed6761bf4eb5 |
|
BLAKE2b-256 | bb22476ff1c6fcd365a389b7f0323d02d1cf6d22d8b8aab2d2f153246b2d81a8 |