Skip to content

Instantly share code, notes, and snippets.

@andreif
Created May 18, 2018 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreif/a2f49f8bc19edcf813a6f36c1766bf7f to your computer and use it in GitHub Desktop.
Save andreif/a2f49f8bc19edcf813a6f36c1766bf7f to your computer and use it in GitHub Desktop.
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
elif settings.IS_LOCAL: # for testing with DEBUG=False
urlpatterns += patterns('',
(r'^%s(?P<path>.*)$' % re.escape(settings.STATIC_URL.lstrip('/')),
'django.contrib.staticfiles.views.serve', {'insecure': True}),
(r'^%s(?P<path>.*)$' % re.escape(settings.MEDIA_URL.lstrip('/')),
'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment