debian-django-admin-rangefi.../README.rst

79 lines
1.6 KiB
ReStructuredText
Raw Permalink Normal View History

2016-08-05 10:42:45 +02:00
.. image:: https://travis-ci.org/silentsokolov/django-admin-rangefilter.svg?branch=master
2016-06-24 12:17:49 +02:00
:target: https://travis-ci.org/silentsokolov/django-admin-rangefilter
2017-04-12 22:04:24 +02:00
.. image:: https://codecov.io/gh/silentsokolov/django-admin-rangefilter/branch/master/graph/badge.svg
:target: https://codecov.io/gh/silentsokolov/django-admin-rangefilter
2016-06-24 12:17:49 +02:00
django-admin-rangefilter
========================
2016-12-27 08:29:05 +01:00
django-admin-rangefilter app, add the filter by a custom date / datetime range on the admin UI.
2016-06-24 12:17:49 +02:00
.. image:: https://raw.githubusercontent.com/silentsokolov/django-admin-rangefilter/master/docs/images/screenshot.png
Requirements
------------
2019-04-10 15:43:40 +02:00
* Python 2.7+ or Python 3.4+
2017-04-12 22:04:24 +02:00
* Django 1.8+
2016-06-24 12:17:49 +02:00
Installation
------------
Use your favorite Python package manager to install the app from PyPI, e.g.
Example:
``pip install django-admin-rangefilter``
Add ``rangefilter`` to ``INSTALLED_APPS``:
Example:
.. code:: python
INSTALLED_APPS = (
...
'rangefilter',
...
)
Example usage
-------------
In admin
~~~~~~~~
.. code:: python
from django.contrib import admin
2016-12-27 08:29:05 +01:00
from rangefilter.filter import DateRangeFilter, DateTimeRangeFilter
2016-06-24 12:17:49 +02:00
2019-05-19 15:32:16 +02:00
from .models import Post
2019-04-10 15:43:40 +02:00
2016-06-24 12:17:49 +02:00
@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
list_filter = (
2016-12-27 08:29:05 +01:00
('created_at', DateRangeFilter), ('updated_at', DateTimeRangeFilter),
2016-06-24 12:17:49 +02:00
)
2019-07-04 08:43:36 +02:00
Support Content-Security-Policy
-------------------------------
2019-07-04 08:45:51 +02:00
For Django 1.8+, if `django-csp <https://github.com/mozilla/django-csp>`_ is installed, nonces will be added to style and script tags.
2019-07-04 08:43:36 +02:00
.. code:: python
INSTALLED_APPS = (
...
'rangefilter',
'csp',
...
)