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.
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.5.tar.gz.
File metadata
- Download URL: django_never_cache-0.1.5.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0708d7e2c03822e2c46222d9ea97d18e5e960a31667d045444e465621be9b86
|
|
| MD5 |
60401b994344be9b8fa5aab54952caff
|
|
| BLAKE2b-256 |
ef3469d5bd445efbf8071c81ba001f18471bad91a98099013ea8700fa58e5834
|
Provenance
The following attestation bundles were made for django_never_cache-0.1.5.tar.gz:
Publisher:
release.yml on trottomv/django-never-cache
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_never_cache-0.1.5.tar.gz -
Subject digest:
a0708d7e2c03822e2c46222d9ea97d18e5e960a31667d045444e465621be9b86 - Sigstore transparency entry: 2613477780
- Sigstore integration time:
-
Permalink:
trottomv/django-never-cache@a98956506be1e89432f8b728751ccf8ce68a547c -
Branch / Tag:
refs/tags/0.1.5 - Owner: https://github.com/trottomv
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a98956506be1e89432f8b728751ccf8ce68a547c -
Trigger Event:
release
-
Statement type:
File details
Details for the file django_never_cache-0.1.5-py3-none-any.whl.
File metadata
- Download URL: django_never_cache-0.1.5-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dedbb88dd5be860beca255c741b58cdf5ed10a09a88d9f126e3f3399bea0d38c
|
|
| MD5 |
14d4957a191e4c86d26e45aa00f99a0a
|
|
| BLAKE2b-256 |
d36c6fccbfecf501c9ca18925570ccfc3666b856e658e04d54f7b9dc3ebcbcc9
|
Provenance
The following attestation bundles were made for django_never_cache-0.1.5-py3-none-any.whl:
Publisher:
release.yml on trottomv/django-never-cache
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_never_cache-0.1.5-py3-none-any.whl -
Subject digest:
dedbb88dd5be860beca255c741b58cdf5ed10a09a88d9f126e3f3399bea0d38c - Sigstore transparency entry: 2613477804
- Sigstore integration time:
-
Permalink:
trottomv/django-never-cache@a98956506be1e89432f8b728751ccf8ce68a547c -
Branch / Tag:
refs/tags/0.1.5 - Owner: https://github.com/trottomv
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a98956506be1e89432f8b728751ccf8ce68a547c -
Trigger Event:
release
-
Statement type: