Revision info for Django static file
Project description
Provide a context variable to retrieve the version of a Django application.
This variable is meant to change the URL of a static file, to invalidate browser cache.
Install
pip3 install dj-static-revision
Django Static Revision only supports Python 3.4+.
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'
Project details
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
Hashes for dj_static_revision-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b48c3d8e22f11fce1ba195184c2a5fe875fbf8e66e313b47060c9acbb2e800b2 |
|
MD5 | 761009f487ab8307f74dbe63eab01ae9 |
|
BLAKE2b-256 | ab8f75d2e4ff43cc7dee67eaf557db46f2cb4995b99c427e146f0046490fc155 |