Skip to main content

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.


pip3 install dj-static-revision

Django Static Revision only supports Python 3.6+.


Add dj_static_revision.context_processors.static_revision to your context_processors list.

        'NAME': 'jinja2',
        'BACKEND': 'django_jinja.backend.Jinja2',
        'OPTIONS': {
            'context_processors': (
                # Other context processors

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 file.


The revision string will be truncated to 10 characters. You can change that by add to Django settings:


You can also change the file for Django Static Revision to read revision string from, by add this setting:


where .version is a text file containing any string you want.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dj-static-revision, version 0.4
Filename, size File type Python version Upload date Hashes
Filename, size dj_static_revision-0.4-py3-none-any.whl (3.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size dj-static-revision-0.4.tar.gz (3.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page