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.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63286a4cb185399a5ab8c7ba3f6624d015aec0e94ae8d4c061f7402ea670ad96 |
|
MD5 | f9ae468f84871abe3f2d3f64e4f3c0e8 |
|
BLAKE2b-256 | 57abad976f2d7cc153dd86d5b18124e52220855525129c127234cafe199423e4 |
Close
Hashes for django_unfold_admin_list_filter_dropdown-1.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e837002f30b30b97ef7aa25e69a56389039921b8bdb9064db5ba84468b8db002 |
|
MD5 | 1740bcc7961e2bcf26af9c63adc5eb3d |
|
BLAKE2b-256 | d06692bf6a3f707a637473de49ae4723fdd28f7d6cb10839dc5225918dc20afa |