django-admin-numeric-filter


Namedjango-admin-numeric-filter JSON
Version 0.1.8 PyPI version JSON
download
home_pagehttps://github.com/lukasvinclav/django-admin-numeric-filter
SummaryNumeric filters for Django admin
upload_time2023-01-13 08:03:19
maintainer
docs_urlNone
author
requires_python>=3.6
licenseMIT
keywords django admin numeric filter
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![Screenshot](https://github.com/lukasvinclav/django-admin-numeric-filter/raw/master/screenshot.png)

# django-admin-numeric-filter

![](https://img.shields.io/badge/Version-0.1.8-orange.svg?style=flat-square)
![](https://img.shields.io/badge/Django-2.0+-green.svg?style=flat-square)
![](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)

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

```bash
pip install django-admin-numeric-filter
```

2. Add **admin_numeric_filter** into **INSTALLED_APPS** in your settings file before **django.contrib.admin**.

## Sample admin configuration

```python
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 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                          |
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/lukasvinclav/django-admin-numeric-filter",
    "name": "django-admin-numeric-filter",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "django,admin,numeric,filter",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/b8/38/83cf9211e88960c8538b2ce33a4a7b2106e06ce70948045c8c90f496445a/django_admin_numeric_filter-0.1.8.tar.gz",
    "platform": null,
    "description": "![Screenshot](https://github.com/lukasvinclav/django-admin-numeric-filter/raw/master/screenshot.png)\n\n# django-admin-numeric-filter\n\n![](https://img.shields.io/badge/Version-0.1.8-orange.svg?style=flat-square)\n![](https://img.shields.io/badge/Django-2.0+-green.svg?style=flat-square)\n![](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)\n\ndjango-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).\n\nDon'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.\n\n## Getting started\n\n1. Installation\n\n```bash\npip install django-admin-numeric-filter\n```\n\n2. Add **admin_numeric_filter** into **INSTALLED_APPS** in your settings file before **django.contrib.admin**.\n\n## Sample admin configuration\n\n```python\nfrom admin_numeric_filter.admin import NumericFilterModelAdmin, SingleNumericFilter, RangeNumericFilter, \\\n    SliderNumericFilter\n\nfrom .models import YourModel\n\n\nclass CustomSliderNumericFilter(SliderNumericFilter):\n    MAX_DECIMALS = 2\n    STEP = 10\n\n\n@admin.register(YourModel)\nclass YourModelAdmin(NumericFilterModelAdmin):\n    list_filter = (\n        ('field_A', SingleNumericFilter), # Single field search, __gte lookup\n        ('field_B', RangeNumericFilter), # Range search, __gte and __lte lookup\n        ('field_C', SliderNumericFilter), # Same as range above but with slider\n        ('field_D', CustomSliderNumericFilter), # Filter with custom attributes\n    )\n```\n\n## Filter classes\n\n| Class name                               | Description                            |\n|------------------------------------------|----------------------------------------|\n| admin_actions.admin.SingleNumericFilter  | Single field search, __gte lookup      |\n| admin_actions.admin.RangeNumericFilter   | Range search, __gte and __lte lookup   |\n| admin_actions.admin.SliderNumericFilter  | Same as range above but with slider    |\n\n\n## Slider default options for certain field types\n\n| Django model field                       | Step                     | Decimal places             |\n|------------------------------------------|--------------------------|----------------------------|\n| django.db.models.fields.DecimalField()   | Based on decimal places  | max precision from DB      |\n| django.db.models.fields.FloatField()     | Based on decimal places  | field decimal_places attr  |\n| django.db.models.fields.IntegerField()   | 1                        | 0                          |",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Numeric filters for Django admin",
    "version": "0.1.8",
    "split_keywords": [
        "django",
        "admin",
        "numeric",
        "filter"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e8f759f62aab3029fdd1ce091537f925a9099bf0090c7b31870a394161ddcdab",
                "md5": "a8a14449e4b19329f18979b1949c5671",
                "sha256": "89052324989d2c6a9bb060c13e1f159800ec9ca8b7f40d2160d710f89c7453d3"
            },
            "downloads": -1,
            "filename": "django_admin_numeric_filter-0.1.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a8a14449e4b19329f18979b1949c5671",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 19190,
            "upload_time": "2023-01-13T08:03:18",
            "upload_time_iso_8601": "2023-01-13T08:03:18.124636Z",
            "url": "https://files.pythonhosted.org/packages/e8/f7/59f62aab3029fdd1ce091537f925a9099bf0090c7b31870a394161ddcdab/django_admin_numeric_filter-0.1.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b83883cf9211e88960c8538b2ce33a4a7b2106e06ce70948045c8c90f496445a",
                "md5": "c3b9c78aff297fcbc3b1a495b6839bdf",
                "sha256": "26edf7d9fc16cd3f8630aa5f4ae84df4253786bcf86d2254185b93cc9fca65ed"
            },
            "downloads": -1,
            "filename": "django_admin_numeric_filter-0.1.8.tar.gz",
            "has_sig": false,
            "md5_digest": "c3b9c78aff297fcbc3b1a495b6839bdf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 16922,
            "upload_time": "2023-01-13T08:03:19",
            "upload_time_iso_8601": "2023-01-13T08:03:19.999204Z",
            "url": "https://files.pythonhosted.org/packages/b8/38/83cf9211e88960c8538b2ce33a4a7b2106e06ce70948045c8c90f496445a/django_admin_numeric_filter-0.1.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-13 08:03:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "lukasvinclav",
    "github_project": "django-admin-numeric-filter",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "django-admin-numeric-filter"
}
        
Elapsed time: 0.09663s