I am using:
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage' in settings.py.
This allows me to use long cache times, and resources are never stale.
Does anyone have an idea how this could be achieved?
Ken’s approach will work fine. For "why use
json_script" see this post.
A second approach, if you’re doing this for many CSS files, is to add a regex to a subclass of
ManifestStaticFilesStorage to have it update references in your JS files. I did this recently in this Django ticket for JS sourcemaps, which can serve as reference.