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.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 579133555621c4f9569e386f8399b13ad529af81906305f5e247ad3a4a982064 |
|
MD5 | 9a9bc7ba4c1c2b4dba290ea9eb55b89d |
|
BLAKE2b-256 | bdc1ee291cf2c349e525a6889aae20792ef0ec0feb60ad59f6718e0ed06eaabe |
Close
Hashes for django_unfold_admin_list_filter_dropdown-1.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65f4e2773901ae899f744f1cd3b531a0a6a541d7387655705f1573666b77cf0c |
|
MD5 | e30a535e9a8feccce9e45b7bf67987f8 |
|
BLAKE2b-256 | 2e24301b26fa9f897d454c44c5a564efe602dfed0b2e4afc83dfa992cd184e61 |