Skip to main content

Date range filter for Django admin

Project description

Django admin date range filter

Build Status GitHub release PyPI release Python version GitHub issues Code quality Coverage GitHub license

Application adds three Django admin list filters: DateRangeFilter, PastDateRangeFilter and FutureDateRangeFilter. These filters let user filter models by date range. PastDateRangeFilter and FutureDateRangeFilter add quick selection of predefined date ranges. Filters can be applied to any model date fields. Application supports default Django admin theme and Suit theme.

Admin screenshot

Requirements

  • Python 2.7+ or Python 3.3+
  • Django 1.9+

Installation

Install django-daterangefilter using pip:

pip install django-daterangefilter

Add daterangefilter to INSTALLED_APPS. Example:

INSTALLED_APPS = (
    ...
    'daterangefilter',
    ...
)

Application uses static files so do not forget to issue collectstatic management command in production environment.

Example usage

in admin.py:

from django.contrib import admin
from daterangefilter.filters import PastDateRangeFilter, FutureDateRangeFilter

@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
    list_filter = [
        ('created_at', PastDateRangeFilter), ('publish_at', FutureDateRangeFilter)
    ]

Advanced usage

Predefined ranges can be completely redefined by overriding _past_ranges.html and _future_ranges.html templates. Take into account that these templates are inserted in the middle of the javascript code and may contain nothing but ranges definition. For more examples on using moment library refer to library documentation.

Credits

Filter widget uses a great JavaScript date range picker component - Date Range Picker by Dan Grossman.

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-daterangefilter-1.0.0.tar.gz (106.1 kB view details)

Uploaded Source

Built Distribution

django_daterangefilter-1.0.0-py2.py3-none-any.whl (111.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-daterangefilter-1.0.0.tar.gz.

File metadata

  • Download URL: django-daterangefilter-1.0.0.tar.gz
  • Upload date:
  • Size: 106.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.3

File hashes

Hashes for django-daterangefilter-1.0.0.tar.gz
Algorithm Hash digest
SHA256 56547903d5b804e57486ed4759a8fd56d710a3ec01458b753300ca190d4e27c0
MD5 cdaddf74d188c8d573237f495c6f18a1
BLAKE2b-256 5380e67ae3e768641cdbf87c1b18ee627d4de94b62ed8fd38c45e2609556d605

See more details on using hashes here.

File details

Details for the file django_daterangefilter-1.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: django_daterangefilter-1.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 111.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.3

File hashes

Hashes for django_daterangefilter-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ece3641e6287b118b517bbcb34ad996b41f8be3ff8cdac05302bfdc688107c34
MD5 dad94916067be7698b23e36b556958de
BLAKE2b-256 d406dd4a34a0d818a5fd7177ac7e7fd923e31da407ee98160e6906e9bae2e674

See more details on using hashes here.

Supported by

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