Revision info for Django static file
Project description
Django plugin to provide a context variable for retrieving the version of running application.
This variable is meant to change the URL of a static file, to invalidate browser cache.
Install
python -m pip install dj-static-revision
# or
uv add dj-static-revision
Django Static Revision only supports Python 3.10+.
Usage
Add dj_static_revision.context_processors.static_revision to your context_processors list.
TEMPLATES = (
{
'NAME': 'jinja2',
'BACKEND': 'django_jinja.backend.Jinja2',
'OPTIONS': {
'context_processors': (
# Other context processors
'dj_static_revision.context_processors.static_revision',
),
A variable REVISION will then exists in your template, you can use it to append to static file URL.
<script src="{{ static('js/app.js') }}?v={{ REVISION }}"></script>
Django Static Revision retrieves revision string from Git history. If your source code is not managed by Git, the revision info will be read from a file named .version placed next to manage.py file.
Settings
The revision string will be truncated to 10 characters. You can change that by add to Django settings:
STATIC_REVISION_STRING_LENGTH = 10
You can also change the file for Django Static Revision to read revision string from, by add this setting:
STATIC_REVISION_VERSION_FILE = '.version'
where .version is a text file containing any string you want.
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 dj_static_revision-0.10.tar.gz.
File metadata
- Download URL: dj_static_revision-0.10.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8888a5ce8d0e330adf7777cad3d9834d4fd4ffa9ee8026db630c21209f5d43be
|
|
| MD5 |
d12fd11ae7d0551fe49a9a1ec0dc0ab7
|
|
| BLAKE2b-256 |
7f3eb5e570554cff1aacf53fbededadd21e75c98fc8dc74caf890316a1866f22
|
File details
Details for the file dj_static_revision-0.10-py3-none-any.whl.
File metadata
- Download URL: dj_static_revision-0.10-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b03885315b6b232aa2c90e829735398e10b66d07101a59428fc2954e3e56bc4
|
|
| MD5 |
a6665e6f5adcada271352fab0bd5ed3c
|
|
| BLAKE2b-256 |
918e4c3a1d6b55b67223cf0139e26d7e866e4899254936bc334a1158cede2131
|