Custom filters for Django Admin
Project description
Custom filters for Django Admin
##Information 1. Custom choice filter
1.1. Filter by multiple choices (Less and Equal, More and Equal, Equal) in each metrics / dimensions lookups
1.2. Add multiple metrics / dimensions for combined queries
1.3. You can add any name for your metrics / dimension to label
2. Custom dropdown filter
2.1. Filter uses default view of django list_filter in condition when values less than slice count (default slice count is 3)
2.2. When values in filter more than slice count view changed to select element.
##Install
You can install this by using pip:
pip install django-admin-custom-filters
##Usage
1. Custom choice filter
1.1. Create child class by using parent class CustomInputChoiceFilter.
from django_admin_custom_filters.filters import CustomInputChoiceFilter
class ChildFilter(CustomInputChoiceFilter):
1.2. Edit variables - title, parameters_title, parameters_name.
from django_admin_custom_filters.filters import CustomInputChoiceFilter
class ChildFilter(CustomInputChoiceFilter):
title = "Test Filter"
parameters_name = ['variable_1', 'variable_2']
parameters_title = ['Variable First', 'Variable Second']
1.3. Create child class by using parent class CustomModelAdmin.
from django_admin_custom_filters.admin import CustomModelAdmin
class TestAdmin(CustomModelAdmin):
1.4. Add to list_filter your filter.
from django_admin_custom_filters.admin import CustomModelAdmin
from .filters import ChildFilter
from .models import Test
class TestAdmin(CustomModelAdmin):
list_filter = (
ChildFilter,
)
class Meta:
model = Test
2. Custom dropdown filter
2.1. You can create child class for change slice count.
from django_admin_custom_filters.filters import DropdownFilter
class CustomDropdownFilter(DropdownFilter):
slice_count = 2
2.2. Add to list_filter your filter.
from django.contrib import admin
from .filters import CustomDropdownFilter
from .models import Test
class TestAdmin(admin.ModelAdmin):
list_filter = (
('variable_1', CustomDropdownFilter),
)
class Meta:
model = Test
3. Img from examples folder code
3.1. Custom choice filter and Custom dropdown filter
3.2. Custom dropdown filter by slice more than values in filter.

Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_admin_custom_filters-0.1.0.tar.gz.
File metadata
- Download URL: django_admin_custom_filters-0.1.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3103e2b866d1cac97073f2780d6739c05fd174128e2a077bd05d1d8c8e908709
|
|
| MD5 |
2a8af24fd4edf1016fccc87f4b259d9a
|
|
| BLAKE2b-256 |
88e32129d2d2632350e0b48334a1fe4b55f791cf484bfc043894675cbf6f4df9
|
File details
Details for the file django_admin_custom_filters-0.1.0-py2.py3-none-any.whl.
File metadata
- Download URL: django_admin_custom_filters-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
895759e8231b24c4a3865dc3f7cf95da617363f0272da25968db290eae7bb899
|
|
| MD5 |
26c178b9db732f48f60771546d37931c
|
|
| BLAKE2b-256 |
bf79135319fc87f59bc9df20dc44af5fcd655510df6cdd60efe35804359667b0
|