A Django app that provides a suite of utilities to disable caching in template views.
Project description
Django Never Cache
This Django app provides a suite of utilities to disable caching in template views.
Prerequisites
- Python >= 3.9
- Django >= 3.2
Installation
-
Install the package via pip:
pip install django-never-cache
-
Add
django_never_cacheto yourINSTALLED_APPSinsettings.py:INSTALLED_APPS = [ ... "django_never_cache", ... ]
Usage
NoCacheMixin
Use NoCacheMixin to disable caching for a view:
from django.views.generic import TemplateView
from django_never_cache.mixins import NoCacheMixin
class MyView(NoCacheMixin, TemplateView):
template_name = "my_template.html"
PrivateAreaMixin
Use PrivateAreaMixin to require login and disable caching for a private area:
from django.views.generic import TemplateView
from django_never_cache.mixins import PrivateAreaMixin
class MyView(PrivateAreaMixin, TemplateView):
template_name = "my_private_template.html"
NoCacheMiddleware
Use NoCacheMiddleware if you want to disable caching for the whole site:
MIDDLEWARE = [
...
"django_never_cache.middleware.NeverCacheMiddleware",
]
If you have setted NeverCacheMiddleware in MIDDLEWARE you can exclude caching for a view using allow_cache decorator.
from django.utils.decorators import method_decorator
from django.views.generic import TemplateView
from django_never_cache.decorators import allow_cache
@method_decorator(allow_cache, name="dispatch")
class MyCachedView(TemplateView):
template_name = "my_cached_template.html"
Contribute
You can contribute to this project on GitHub.
Prerequisites
- tox
- Golang >= 1.21
How to Contribute
- Fork the repository.
- Create a new branch:
git checkout -b my-branch-name. - Install
pre-commitwithpre-commit installand make your changes. - Commit your changes:
git commit -am "Add some feature". - Push your branch:
git push origin my-branch-name. - Create a pull request.
Run tests
To run the tests, run the following command:
tox
License
This project is released under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_never_cache-0.1.2.tar.gz.
File metadata
- Download URL: django_never_cache-0.1.2.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9fb38c5aadaeb01ebcf655e9a1c19995fc4bb0b4d6e64a7a30b682b1d82ea8c
|
|
| MD5 |
3f134034b03719d4969b94c39c0527d9
|
|
| BLAKE2b-256 |
24730270a2b9340b6705c7696547852c99ceecfe6b9130b7d7f4e2b6319ac1fb
|
File details
Details for the file django_never_cache-0.1.2-py3-none-any.whl.
File metadata
- Download URL: django_never_cache-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
595dad66ea1fc6fd8dba46fa53e59df3b8ee80eff5eb115682f9b98b7fcaab84
|
|
| MD5 |
527ab65ed7808691391c700164f908e6
|
|
| BLAKE2b-256 |
c1fd51e85a012fbc82591d782bf32028ecf9afd16214a51ed0a584a1a66c0f66
|