5 ms·
Instead of prefixing everything with {{ STATIC_URL }} in your templates, use the template tag {% static 'foo/bar/img' %} which will allow you to do asset time-s
by nulluk 14y ago
Instead of prefixing everything with {{ STATIC_URL }} in your templates, use the template tag {% static 'foo/bar/img' %} which will allow you to do asset time-stamping/versioning,
https://docs.djangoproject.com/en/dev/howto/static-files/#with-a-template-tag https://docs.djangoproject.com/en/dev/howto/static-files/#wi...
Edit: forgot to link to the versioning part in the docs: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#cachedstaticfilesstorage https://docs.djangoproject.com/en/dev/ref/contrib/staticfile...
Edit edit: ADMIN_MEDIA_PREFIX is also depreciated from 1.4 onwards: https://docs.djangoproject.com/en/1.4/releases/1.4/#django-contrib-admin https://docs.djangoproject.com/en/1.4/releases/1.4/#django-c...
- larkinrichards 14y agoGood point. Delegating to the storage backend instead of using a STATIC_URL is a don't-repeat-yourself solution. It's interesting that the CachedStaticFilesStorage will replace urls inside of CSS (as part of the time-stamping), but the standard Storage won't do it to change paths for development/production. As it stands, I use production urls in CSS so that I don't have to change it when I deploy.
- nulluk 14y agoUsing relative paths in your css generally resolves that issue, is there a specific reason that doesn't work in your use case?
- larkinrichards 14y agoNo, that's actually what I should be doing here. Thanks for mentioning it!