diff --git a/settings.py.dist b/settings.py.dist index beea8a394b..1a97997052 100755 --- a/settings.py.dist +++ b/settings.py.dist @@ -45,6 +45,13 @@ SITE_ID = 1 # to load the internationalization machinery. USE_I18N = False +# If you'd like to serve media files via Django (strongly not recommended!), +# set SERVE_MEDIA to True. This is appropriate on a developing site, or if +# you're running Django's built-in test server. Normally you want a webserver +# that is optimized for serving static content to handle media files (apache, +# lighttpd). +SERVE_MEDIA = False + # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" MEDIA_ROOT = '%s/media' % (BASE_PATH) diff --git a/urls.py b/urls.py index 56e7b798cd..9ccea53526 100755 --- a/urls.py +++ b/urls.py @@ -7,11 +7,22 @@ # from django.conf.urls.defaults import * +import settings urlpatterns = patterns('', - # Admin interface - (r'^admin/', include('django.contrib.admin.urls')), + # Admin interface + (r'^admin/', include('django.contrib.admin.urls')), - # Front page - (r'^', include('apps.website.urls')), + # Front page + (r'^', include('apps.website.urls')), ) + +# If you'd like to serve media files via Django (strongly not recommended!), +# open up your settings.py file and set SERVE_MEDIA to True. This is +# appropriate on a developing site, or if you're running Django's built-in +# test server. Normally you want a webserver that is optimized for serving +# static content to handle media files (apache, lighttpd). +if settings.SERVE_MEDIA: + urlpatterns += patterns('', + (r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), + ) \ No newline at end of file