serve static files for development

This commit is contained in:
Jeff Balogh 2009-10-20 19:20:38 -07:00
Родитель 93d7493556
Коммит 3bedd697b9
1 изменённых файлов: 9 добавлений и 4 удалений

13
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<path>.*)$' % media_url, 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT})
)