diff --git a/urls.py b/urls.py index cea7f86452..a1d39194fd 100644 --- a/urls.py +++ b/urls.py @@ -1,9 +1,6 @@ +from django.conf import settings from django.conf.urls.defaults import * -# Uncomment the next two lines to enable the admin: -# from django.contrib import admin -# admin.autodiscover() - urlpatterns = patterns('', # Example: # (r'^zamboni/', include('zamboni.foo.urls')), @@ -15,3 +12,11 @@ urlpatterns = patterns('', # Uncomment the next line to enable the admin: # (r'^admin/', include(admin.site.urls)), ) + +if settings.DEBUG: + # Remove leading and trailing slashes so the regex matches. + media_url = settings.MEDIA_URL.lstrip('/').rstrip('/') + urlpatterns += patterns('', + (r'^%s/(?P.*)$' % media_url, 'django.views.static.serve', + {'document_root': settings.MEDIA_ROOT}) + )