Skip to main content

Numeric filters for Django admin

Project description

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
pip install git+https://git@github.com/lukasvinclav/django-admin-numeric-filter.git
  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


@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
    )

Filter classes

Class name Description
admin_actions.admin.SingleNumericFilter Single field search, __gte lookup
admin_actions.admin.RangeNumericFilter Range search, __gte and __lte lookup
admin_actions.admin.SliderNumericFilter Same as range above but with slider

Slider default options for certain field types

Django model field Step Decimal places
django.db.models.fields.DecimalField() Based on decimal places max precision from DB
django.db.models.fields.FloatField() Based on decimal places field decimal_places attr
django.db.models.fields.IntegerField() 1 0

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

django-admin-numeric-filter-0.1.3.tar.gz (16.2 kB view details)

Uploaded Source

File details

Details for the file django-admin-numeric-filter-0.1.3.tar.gz.

File metadata

  • Download URL: django-admin-numeric-filter-0.1.3.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5

File hashes

Hashes for django-admin-numeric-filter-0.1.3.tar.gz
Algorithm Hash digest
SHA256 39ed381d16c7c5a0a5675590cd73b02341c15223f241cf41abde22cfad498c93
MD5 6de0bf4963d079675db4f1bbfa66a4e3
BLAKE2b-256 5a6b958827bf30d6a6f03a1ee64c45d90ab3b8afa301635a73e23395be33c811

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page