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.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f00b7a70c31ac850195c655fc48f7b5499c838b30aae9780d4e0551c30a0a9d4 |
|
MD5 | 0c4b73e429e8d8a8dbdba65fdc3694e7 |
|
BLAKE2b-256 | 1474484ab12ee7aa17c81288b49ab8c420397e1a492f8ff9114e15c3689e36a5 |
Close
Hashes for django_unfold_admin_list_filter_dropdown-1.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1cc0ccdca63302a7195f34be4a3631a8b15f28292a503544ee0596f9dc0821b |
|
MD5 | 98cf1f5af41d6a969a9012b347612f28 |
|
BLAKE2b-256 | 22de132d7cd06c7ba34861b2363d57e738d6fb624169677045061af779ab1b4d |