Skip to content

Instantly share code, notes, and snippets.

@hcliff
Created September 18, 2013 14:45
Show Gist options
  • Save hcliff/6610224 to your computer and use it in GitHub Desktop.
Save hcliff/6610224 to your computer and use it in GitHub Desktop.
Example dev media serving
from django.conf import settings
# Create your urlpatterns here
if settings.DEBUG:
urlpatterns = patterns('django.views.static',
(r'^%s/(?P<path>.*)$' % settings.MEDIA_URL.strip('/'), 'serve',
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
(r'^%s/(?P<path>.*)$' % settings.DEV_MEDIA_URL.strip('/'), 'serve',
{'document_root': settings.GENERATED_MEDIA_DIR, 'show_indexes': True}),
(r'^%s/(?P<path>.*)$' % settings.STATIC_URL.strip('/'), 'serve',
{'document_root': settings.STATIC_ROOT, 'show_indexes': True}),
) + urlpatterns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment