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
Close
Hashes for django_unfold_admin_list_filter_dropdown-1.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b174aa418d9ac1f1cf9d04b178d8ef6d244f0f5cb07394c1b52f25f198aa9694 |
|
MD5 | 492e105ea076292e4537676ba75b570a |
|
BLAKE2b-256 | c5867309d87b19e9ecf95ad46d50adf2b88f77277d1302a6a036d1c569659941 |
Close
Hashes for django_unfold_admin_list_filter_dropdown-1.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fa6857e067f1beda51f2cc13c078311b891e8dbb9a6a44466af852d12c327f5 |
|
MD5 | 30c7162a568f791388b0d52332c7033f |
|
BLAKE2b-256 | 602671e8735d7283627d8d2a3620e1af15d1fa86c67dda0ff1234a87b0b53742 |