A {% versioned_static %} template tag for generating cache-busting static URLs
Python
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
canonicalwebteam
.gitignore
CHANGES.txt
LICENSE.txt
MANIFEST.in
README.rst
setup.cfg
setup.py

README.rst

canonical-webteam.versioned-static

A {% versioned_static %} Django template tag for generating a URL for a static file, with a version string which will be effectively unique based on the contents of the file.

Example

/static/css/global.css?v=a23bd10

Installation

# settings.py
INSTALLED_APPS += ['django_versioned_static_url']

Usage

The following template code:

{% load versioned_static %}
<link rel="stylesheet" href="{% versioned_static 'css/global.css' %}" />

Outputs:

<link rel="stylesheet" href="/static/css/global.css?v=feb0d0e" />