Skip to content

Instantly share code, notes, and snippets.

@Apkawa
Created December 13, 2016 12:25
Show Gist options
  • Save Apkawa/05a590ea85ff64eee91d3b0b317e49a5 to your computer and use it in GitHub Desktop.
Save Apkawa/05a590ea85ff64eee91d3b0b317e49a5 to your computer and use it in GitHub Desktop.
RevisionStaticFileStorage pass settings.STATIC_REV to url
# coding: utf-8
from __future__ import unicode_literals
from django.conf import settings
from django.contrib.staticfiles.storage import StaticFilesStorage
class RevisionStaticFilesStorage(StaticFilesStorage):
def url(self, name):
version = getattr(settings, 'STATIC_REV', None)
url = super(RevisionStaticFilesStorage, self).url(name)
return "{}?r={}".format(url, version)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment