Skip to main content

Date range filter for Django admin

Project description

Django admin date range filter

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 dj-daterangefilter using pip:

pip install dj-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

dj-daterangefilter-0.1.2.tar.gz (107.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dj_daterangefilter-0.1.2-py3-none-any.whl (111.1 kB view details)

Uploaded Python 3

File details

Details for the file dj-daterangefilter-0.1.2.tar.gz.

File metadata

  • Download URL: dj-daterangefilter-0.1.2.tar.gz
  • Upload date:
  • Size: 107.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for dj-daterangefilter-0.1.2.tar.gz
Algorithm Hash digest
SHA256 86e1972883ba18887ee52ada6c61c45234884d5c27506aa158f5b1219f2e61f6
MD5 1c9a6221370f4e598157e373ce43bd57
BLAKE2b-256 d0f172aa21ed79bff8247b4c0de2db19be6a40b5eb3b43e84dde4c49b7485363

See more details on using hashes here.

File details

Details for the file dj_daterangefilter-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for dj_daterangefilter-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d7eb873eb7775870af692cf12c0c709e9d2301e7d568b80bda6a013f45c26fa0
MD5 d0537558f82d34a793229d79db460dd7
BLAKE2b-256 c757b9d0a89da0611975030cb85bf2535ef37885e94dcedea49b4f9e02bb803d

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