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.1.tar.gz (107.7 kB view details)

Uploaded Source

Built Distribution

django_daterangefilter-1.0.1-py2.py3-none-any.whl (111.3 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: django-daterangefilter-1.0.1.tar.gz
  • Upload date:
  • Size: 107.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2

File hashes

Hashes for django-daterangefilter-1.0.1.tar.gz
Algorithm Hash digest
SHA256 fd1209b3710fbaad1e61a772bc2af1664037663460d90c6a7d58b5b7a73a7027
MD5 24a8e2f29dd0348a80842245deb2d8cc
BLAKE2b-256 9a7f66cf348f699c8bc6295b1211d46ce6de7c36048c234df435a46959a03962

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_daterangefilter-1.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 111.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2

File hashes

Hashes for django_daterangefilter-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 87aba1cd8ddd1345db046fd6951ae7878df8876d8b8bf6360352e01dc5f181db
MD5 521e3662fe6b2131c44ae67d302adc28
BLAKE2b-256 ac513d295c63d46dd79ef417b3b9f054d7e1730d8cf36751c0019798e130d59e

See more details on using hashes here.

Supported by

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