Skip to main content

Allow to filter by a custom date range on the Django Admin

Project description

.. image:: https://travis-ci.org/tzulberti/django-datefilterspec.svg?branch=master
:alt: Build status
:target: https://travis-ci.org/tzulberti/django-datefilterspec

django-daterange-filter
=======================

Add the option to filter by a custom date range on the admin. This allows
to inputs to be used to get the custom date range filters.

See datefilter.png of a screenshot of how this is seen on the admin.

**IMPORTANT:** this will work with Django 1.4. I won't work with previous Django
versions.

Installation
------------

Use pip/easy_install

.. code-block:: bash

pip install django-daterange-filter


Add daterange_filter to settings.INSTALLED_APP. For this, edit the setup.py
file:

.. code-block:: python

INSTALLED_APPS = (
...
'daterange_filter'
)

After this, if you have a model like this one:

.. code-block:: python

class MyModel(models.Model):
...
foo = models.CharField(max_length=1, choices=BAR_CHOICES)
created_at = models.DateField()


To allow to filter the **created_at** field using the date ranges, you must
edit the admin.ModelAdmin referenced to that class:

.. code-block:: python

from daterange_filter.filter import DateRangeFilter
from django.contrib import admin
from models import MyModel

class MyModelAdmin(admin.ModelAdmin):
list_filter = (
'foo',
('created', DateRangeFilter), # this is a tuple
...
)


DateRangeFilter honours localization and supports local date
formats for filtering.

Running tests
-------
First :code:`pip install -r requirements.txt`, then :code:`python ./runtests.py`

If you wanna run tests on all supported Python/Django versions, execute :code:`tox`.

Changes
-------

1.2.0:

* Added support to Django 1.4. Special thanks to: https://github.com/eduardo-matos
* Fix calendar location. Special thanks to: https://github.com/sariogonfer
* Added portugues translations. Special thanks to: https://github.com/Gustavosdo

1.1.1:

* Special thanks to: https://github.com/mightygraf

0.2.0:

* Updated README
* Works with DateTime (special thanks to Andrea Rabbaglietti)

0.1.1:

* Removed the custom DateRangeField
* Improved i18n
* Special thanks to: https://github.com/DXist

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-filter-1.2.0.tar.gz (4.8 kB view details)

Uploaded Source

File details

Details for the file django-daterange-filter-1.2.0.tar.gz.

File metadata

File hashes

Hashes for django-daterange-filter-1.2.0.tar.gz
Algorithm Hash digest
SHA256 9eae4cabfee4553c0d7e583a9065a369411042a650a811f2b4a7e795db6586eb
MD5 10300b584190ee080c1bfa6bd63b1b17
BLAKE2b-256 8e0924f6fc6f03858a89d5404d02f6db0fa588182a275642fb2070e2af7f1875

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