Skip to main content

License: MIT CI PyPI Python Versions Django Versions Django Packages

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

  1. Install the package via pip:

    pip install django-never-cache
    
  2. Add django_never_cache to your INSTALLED_APPS in settings.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.

  1. Fork the repository.
  2. Create a new branch: git checkout -b my-branch-name.
  3. Install pre-commit with pre-commit install and make your changes.
  4. Commit your changes: git commit -am "Add some feature".
  5. Push your branch: git push origin my-branch-name.
  6. 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)

Source distribution for django-never-cache 0.1.5
File Size Uploaded
django_never_cache-0.1.5.tar.gz 8.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-never-cache 0.1.5
File Interpreter ABI Platform
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 log

Release 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

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page