Serve static and media files by Django while in Debug mode

Feb 12, 2014 · by Tim Kamanin

Media and static files won't be served in devel mode untill you put this at the end of the main 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}),

Want to get more 🔥 tips like this one?

Subscribe to get notified about new dev tutorials