Skip to main content

A DateRange Filter for Django Admin Changelists

Project description

Adds a form with AdminDateWidgets that can be used to select a range of dates for filtering the list of records displayed in an admin Changelist.

https://raw.githubusercontent.com/StuartMacKay/django-daterange-filterspec/master/docs/images/screenshot.png

Quick start

Install the package from PyPI:

pip install django-daterange-filterspec

The package includes a template, which loads Django’s calendar widget and date shortcuts. Add the package to the INSTALLED_APPS setting so the template loader can find it:

INSTALLED_APPS = (
    ...
    "daterange.apps.DateRangeFilterConfig",
    ...
)

In your ModelAdmin, set the template used for the changelist to the one provided by the package. Then, for each field you want to filter on create a tuple with the name of the field and the DateRangeFilter filter class:

from django.contrib import admin

from daterange.filters import DateRangeFilter

from .models import Article


@admin.register(Article)
class ArticleAdmin(admin.ModelAdmin):

    list_display = ["title", "slug", "published"]
    list_filter = [("published", DateRangeFilter)]
    ordering = ["-created"]

    change_list_template = "admin/daterange/change_list.html"

Now, go forth and filter!

Project

If you check out the project from the repository there is a fully functioning Django site that you can use to see the filter in action.

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-daterange-filterspec-2.0.1.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

django_daterange_filterspec-2.0.1-py2.py3-none-any.whl (12.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-daterange-filterspec-2.0.1.tar.gz.

File metadata

  • Download URL: django-daterange-filterspec-2.0.1.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for django-daterange-filterspec-2.0.1.tar.gz
Algorithm Hash digest
SHA256 c10ab96ace6b9cde73ec37fb74e8386034ecfe0a6981650341990d393e71616c
MD5 588d3bdf896b4ce3a0d2459fd52df5a9
BLAKE2b-256 11e2c865f2b7df62d00f398dac8c5738d3047513966060f7ce4b0ec60b96705b

See more details on using hashes here.

File details

Details for the file django_daterange_filterspec-2.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: django_daterange_filterspec-2.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for django_daterange_filterspec-2.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f10d1be5c80fbbd9f1531265bbbaf917c595bbf2327935b47eeffad6940278ec
MD5 ff0d46dac16f9b5df7037ca3611c6651
BLAKE2b-256 7a735db87adbeb26c00375614f682fcadd9b21105aba70eb61d93fb4505c5826

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