Provide a django middleware that take care to persist the querystring in the browser cookies or in the Django Request object.
Project description
Django Persistent Filters
Django Persistent Filters is a Python package which provide a django middleware that take care to persist the querystring in the browser cookies or in the Django Request object.
If you have a ListView with a Form for filter the objects, this package is perfect for you!
Installation
Use the package manager pip to install:
pip install django-persistent-filters
Usage
Put the middleware in the settings.py
file:
MIDDLEWARE = [
...,
"persistent_filters.middleware.PersistentFiltersMiddleware"
]
If you want to store filters in the Request object instead Cookies, add in the settings.py
file:
PERSISTENT_FILTERS_IN_REQUEST = True
Add the urls with a filter form in settings.py
file:
PERSISTENT_FILTERS_URLS = [
# You can use name urls
reverse_lazy("user:list"),
# or you can write the path without domain
"/user/list"
]
Add in the form the button for reset filters:
<button type="submit" name="reset-filters">Reset</button>
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
Hashes for django-persistent-filters-1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 563f749c8018ef95a8577277a77a12e4ab012be13c8f92f502d4e20d357eb97e |
|
MD5 | d6b9914f5e091a9e402ac171e6053bf4 |
|
BLAKE2b-256 | 9f0e796256ab368b0cfd662b3ed411fbda4b5d0190df3ae6f200ada21fa81521 |