Laurent
Laurent

Reputation: 1806

Django versioning static files at collectstatic

I'm looking for a way to add a version to all the static files found during a collectstatic.

The goal is to force reload of cached static file. For example if the static file source is src="/jquery/jquery.min.js" I want after the collectstatic to add the date to have src="/jquery/jquery.min.js?date=2015-10-1T10:31:42"

What is the best way to do that ?

Edit : I'm using django 1.4.2

Edit 2 : Eventually, I've updated my app to django 1.8.5

Upvotes: 1

Views: 762

Answers (2)

vsd
vsd

Reputation: 1473

Using ManifestStaticFilesStorage could help.

Upvotes: 2

Wtower
Wtower

Reputation: 19902

One possibility is to use django-versioned-static:

This little apps helps to manage your staticfiles when you need to minify them for production use. Moreover, it is capable of versioning the assets so that whenever you need to alter the static files, users won’t be given old file from the browser cache.

Upvotes: 0

Related Questions