diff --git a/rdmo/core/settings.py b/rdmo/core/settings.py index 237846cef6..3aa1b744c0 100644 --- a/rdmo/core/settings.py +++ b/rdmo/core/settings.py @@ -163,6 +163,8 @@ 'compressor.finders.CompressorFinder', ) +STATICFILES_STORAGE = 'rdmo.core.storage.VersionedStaticFilesStorage' + DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', diff --git a/rdmo/core/storage.py b/rdmo/core/storage.py new file mode 100644 index 0000000000..6039f1c8d4 --- /dev/null +++ b/rdmo/core/storage.py @@ -0,0 +1,18 @@ +from django.conf import settings +from django.contrib.staticfiles.storage import StaticFilesStorage + +from rdmo import __version__ + + +class VersionedStaticFilesStorage(StaticFilesStorage): + + def url(self, name): + url = super().url(name) + + if settings.DEBUG: + return url + else: + if '?' in url: + return f'{url}&v={__version__}' + else: + return f'{url}?v={__version__}'