Consider the following setup:
urls.py
if not settings.PRODUCTION: urlpatterns += patterns('', (r'^admin-media/(?P<path>.*)$', 'django.views.static.serve',{'document_root': settings.LOCAL_ADMIN_MEDIA_ROOT, 'show_indexes': True}), (r'^media/(?P<path>.*)$', 'django.views.static.serve',{'document_root': settings.LOCAL_MEDIA_ROOT, 'show_indexes': True}), )
settings.py
if not PRODUCTION: ADMIN_MEDIA_PREFIX = '/admin-media/'
So, when launched on a local development server, media files must be served through servers, right? A media route was found, however, "Permission denied" is returned for each request (but only one administrator medium, normal media is working fine).
So, I checked something. It turns out that the ADMIN_MEDIA_PREFIX parameter ADMIN_MEDIA_PREFIX set to the same value as the route ...
(r'^admin-media/(?P<path>.*)$', 'django.views.static.serve', ... ), ADMIN_MEDIA_PREFIX = '/admin-media/'
... then the winning server will always return "Permission denied."
However, if ADMIN_MEDIA_PREFIX is different from the route name ...
(r'^admin-media/(?P<path>.*)$', 'django.views.static.serve', ... ), ADMIN_MEDIA_PREFIX = '/non-sense-prefix/'
... then the files will be served (although I have to manually look through them to see them, since all media links are broken into http: // localhost: 8000 / non-sense-prefix / whatever.jpg ).
What is the deal here?
At the same time, I solved the problem with a small hack to change directories ...
(r'^admin-media/(?P<path>.*)$', 'django.views.static.serve', ... ), ADMIN_MEDIA_PREFIX = '/admin-media/../admin-media/'
... but I would prefer to configure this correctly. It seems django is trying to be smart and do something on my behalf, but to delve into the process. Any ideas?
EDIT - I manually maintain the administration tools because I use grappelli, which provides admin template / media replacement.