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.
Metadata
Release files for dj-static-revision 0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dj_static_revision-0.10.tar.gz | 3.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dj_static_revision-0.10-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.2 kB
Release files / dj_static_revision-0.10.tar.gz
| Download URL | dj_static_revision-0.10.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8888a5ce8d0e330adf7777cad3d9834d4fd4ffa9ee8026db630c21209f5d43be
|
|
BLAKE2b-256 checksum How to use checksums |
7f3eb5e570554cff1aacf53fbededadd21e75c98fc8dc74caf890316a1866f22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.8
|
Release files / dj_static_revision-0.10-py3-none-any.whl
| Download URL | dj_static_revision-0.10-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1b03885315b6b232aa2c90e829735398e10b66d07101a59428fc2954e3e56bc4
|
|
BLAKE2b-256 checksum How to use checksums |
918e4c3a1d6b55b67223cf0139e26d7e866e4899254936bc334a1158cede2131
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.8
|