Django Never Cache
This Django app provides a suite of utilities to disable caching in your sensitive views.
Requirements
- Python >= 3.8
- 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
Mixins
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"
NeverCacheMiddleware
Use NeverCacheMiddleware if you want to disable caching for the whole site:
MIDDLEWARE = [
...
"django_never_cache.middlewares.NeverCacheMiddleware",
]
allow_cache
If you have added NeverCacheMiddleware to MIDDLEWARE, you can re-enable caching for a specific view using the 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"
allow_cache supports both synchronous and asynchronous views.
Development
Prerequisites
- tox
- Golang >= 1.21
Run tests
To run the tests, run the following command:
tox
Contribute
You can contribute to this project on GitHub.
- 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.
License
This project is released under the MIT License.
Metadata
Release files for django-never-cache 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_never_cache-0.1.5.tar.gz | 8.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_never_cache-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.0 kB
Release files / django_never_cache-0.1.5.tar.gz
| Download URL | django_never_cache-0.1.5.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a0708d7e2c03822e2c46222d9ea97d18e5e960a31667d045444e465621be9b86
|
|
BLAKE2b-256 checksum How to use checksums |
ef3469d5bd445efbf8071c81ba001f18471bad91a98099013ea8700fa58e5834
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logRelease files / django_never_cache-0.1.5-py3-none-any.whl
| Download URL | django_never_cache-0.1.5-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dedbb88dd5be860beca255c741b58cdf5ed10a09a88d9f126e3f3399bea0d38c
|
|
BLAKE2b-256 checksum How to use checksums |
d36c6fccbfecf501c9ca18925570ccfc3666b856e658e04d54f7b9dc3ebcbcc9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency log