Skip to main content
Background Image

Automatic Static Media Folder

·55 words·1 min

Added another shortcut… I had a config variable in my settings_local file to specify where the media folder was in order to have django static serve it.

This is much easier.

urls.py:

1
2
3
4
5
6
if DEBUG:
    import os
    media_root = os.path.join(PROJECT_ROOT, 'media')
    urlpatterns += patterns ('',
        (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': media_root}),
    )
Phillip Campbell
Author
Phillip Campbell