Serve static and media files by Django while in Debug mode

12 Feb · by Tim Kamanin · 1 min read

Media and static files won't be served in devel mode untill you put this at the end of the main urls.py file:

if settings.DEBUG:
  urlpatterns += patterns('',
    (r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
    (r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
  )

Comments

Required for comment verification