Add a DEVELOPMENT settings for URL mapping for static and media files.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Fri, 14 Jan 2011 04:05:24 +0530
changeset 396 08893f05cc3d
parent 395 5c6e2478663d
child 397 68759310b1f3
Add a DEVELOPMENT settings for URL mapping for static and media files.
pytask/urls.py
--- a/pytask/urls.py	Fri Jan 14 04:05:05 2011 +0530
+++ b/pytask/urls.py	Fri Jan 14 04:05:24 2011 +0530
@@ -1,15 +1,12 @@
+from django.conf import settings
 from django.conf.urls.defaults import *
 
 from registration.views import register
-from registration.backends.default import DefaultBackend
-import pytask.profile.regbackend
 
 from pytask.profile.forms import CustomRegistrationForm
 from pytask.views import home_page
 
-from django.shortcuts import redirect
 
-# Uncomment the next two lines to enable the admin:
 from django.contrib import admin
 admin.autodiscover()
 
@@ -36,3 +33,12 @@
     (r'^task/', include('pytask.taskapp.urls')),
     (r'^$', home_page),
 )
+
+# Serve static files in DEVELOPMENT = True mode
+if settings.DEVELOPMENT:
+    urlpatterns += patterns('',
+        (r'^pytask/media/(?P<path>.*)$', 'django.views.static.serve',
+         {'document_root': settings.MEDIA_ROOT}),
+        (r'^pytask/static/(?P<path>.*)$', 'django.views.static.serve',
+         {'document_root': settings.STATIC_ROOT}),
+    )