dan
django-admin-numeric-filter
pypi i django-admin-numeric-filter
dan

django-admin-numeric-filter

Numeric filters for Django admin

by Lukas Vinclav

0.1.6 (see all)Categories:Django Range Slider
pypi i django-admin-numeric-filter
Readme

Screenshot

django-admin-numeric-filter

django-admin-numeric-filter provides you several filter classes for Django admin which you can use to filter results in change list. It works in list_filter when a field name is defined as list where the first value is field name and second one is custom filter class (you can find classes below).

Don't forget to inherit your model admin from admin_actions.admin.NumericFilterModelAdmin to load custom CSS styles and JavaScript files declared in inner Media class.

Getting started

  1. Installation
pip install django-admin-numeric-filter
  1. Add admin_numeric_filter into INSTALLED_APPS in your settings file before django.contrib.admin.

Sample admin configuration

from admin_numeric_filter.admin import NumericFilterModelAdmin, SingleNumericFilter, RangeNumericFilter, \
    SliderNumericFilter

from .models import YourModel


class CustomSliderNumericFilter(SliderNumericFilter):
    MAX_DECIMALS = 2
    STEP = 10


@admin.register(YourModel)
class YourModelAdmin(NumericFilterModelAdmin):
    list_filter = (
        ('field_A', SingleNumericFilter), # Single field search, __gte lookup
        ('field_B', RangeNumericFilter), # Range search, __gte and __lte lookup
        ('field_C', SliderNumericFilter), # Same as range above but with slider
        ('field_D', CustomSliderNumericFilter), # Filter with custom attributes
    )

Filter classes

Class nameDescription
admin_actions.admin.SingleNumericFilterSingle field search, __gte lookup
admin_actions.admin.RangeNumericFilterRange search, gte and lte lookup
admin_actions.admin.SliderNumericFilterSame as range above but with slider

Slider default options for certain field types

Django model fieldStepDecimal places
django.db.models.fields.DecimalField()Based on decimal placesmax precision from DB
django.db.models.fields.FloatField()Based on decimal placesfield decimal_places attr
django.db.models.fields.IntegerField()10

GitHub Stars

51

LAST COMMIT

2yrs ago

MAINTAINERS

1

CONTRIBUTORS

7

OPEN ISSUES

5

OPEN PRs

2
VersionTagPublished
0.1.6
3yrs ago
0.1.5
3yrs ago
0.1.4
3yrs ago
0.1.3
3yrs ago
No tutorials found
Add a tutorial