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.9.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8019a177cec91c0c3242e92a7633487c9681c0033a78f1586a0b22bec9c4707 |
|
MD5 | 2967aef5cfb2d8dc58a20b5ec899d095 |
|
BLAKE2b-256 | 504141535e6536affb93266691dd1f988a94acfbac8f8c4697e820cf0feb71bc |
Close
Hashes for django_unfold_admin_list_filter_dropdown-1.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f58bd19a3ad69ac6c40a2b331d1cf843a800c10d31f6077a4d01128f584ee337 |
|
MD5 | fd7171a0ae354118654ab891a1746cfe |
|
BLAKE2b-256 | df8c40d0262e015ec11874dbd08a0b459c59c59107049de64f709a4e08429e7e |