django-localdevstorage icon indicating copy to clipboard operation
django-localdevstorage copied to clipboard

Make sure the MEDIA_URL setting is respected when building urls

Open anrie opened this issue 10 years ago • 6 comments
trafficstars

Just a little fix so that the MEDIA_URL setting is respected (again).

anrie avatar Aug 28 '15 13:08 anrie

@anrie thanks for your pull request, and sorry for the slow response! Can you give a quick example (or even better, a test ☺️) what case this fixes?

beniwohli avatar Sep 04 '15 08:09 beniwohli

@piquadrat I hope this test illustrates the issue. I am basically reverting/correcting this change (https://github.com/piquadrat/django-localdevstorage/commit/c7045d2ed8a21403978b1a3fe7b4dc32b84fe245#diff-c9df30405b26cdf3aad319072b358fe7R37). The _url-method introduced in this change behaves slightly different than Django's url-method (https://github.com/django/django/blob/master/django/core/files/storage.py#L312), that it replaces. Not sure if this change happened intentionally or accidentally. After c7045d2 the MEDIA_URL setting is ignored when constructing the urls and so I see broken urls and consequently no files are downloaded.

anrie avatar Sep 04 '15 13:09 anrie

Yeah, I'm seeing this as well. URLs lack the /media/ part, and because of this all media file access fails.

matthiask avatar Jan 20 '16 11:01 matthiask

Hi, Will this ever go in, or would the best way be for me to merge myself?

madslundgaard avatar Jan 12 '17 12:01 madslundgaard

Sorry for the plug, but if you're only using HTTP you might want to switch to https://github.com/matthiask/django-http-fallback-storage.

(Related: https://twitter.com/suppensud/status/769102478918942720)

matthiask avatar Jan 12 '17 13:01 matthiask

Awesome, thanks @matthiask

madslundgaard avatar Jan 12 '17 13:01 madslundgaard