Comfortable development mode in Django
Friday, July 28th, 2006If you run django in development mode, you need to tell it to serve static files by itself. If you use django in production mode, your http-deamon should handle that for you. You can automate the switchover by an appropriate urls.py setting:
from django.conf.urls.defaults import *
from django.conf import settings
urlpatterns = patterns('',
(r'^admin/', include('django.contrib.admin.urls')),
(r'^r/', include('django.conf.urls.shortcut')),
(r'^comments/', include('django.contrib.comments.urls.comments')),
[...]
)
if settings.DEBUG:
urlpatterns += patterns('',
(r'^media/(?P.*)$',
'django.views.static.serve', {'document_root': '../media'}),
)

