theatlantic/django-autosave

Use storage backend to generate URLs for admin form media

jaylett opened this issue · 0 comments

Originally as a PR, but we thought we didn't need it. However it turns out that all Django is doing at the moment is to tack STATIC_URL on the front, which is wrong for more complex storage backends. For now you have to do the wrapping yourself to be compatible with things like the hashed file storage approach mentioned in the PR. (See a Django core commit within contrib.admin, for example.)

There's also a Django bug for fixing this "properly". Looks like the idea was to have a staticfiles-specific subclass of forms.Media or successor. However that's three years ago, and it doesn't actually solve things if you want to deploy someone else's (eg) extension with staticfiles support… (I've added a comment about this, and when I have time — ha! — will try to pick it up and get to a suitable design decision, at least.)

Note that in the case of admin extensions (as per the Django core commit above), the admin_static template library may be the correct approach.