From 9555ddfdffa88e13880b3da07e2dffd1ecd0b015 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Fri, 27 Jan 2012 13:18:12 -0800 Subject: [PATCH] DEBUG=True is not required to serve static files in Django --- settings.py | 6 ++++-- urls.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/settings.py b/settings.py index 6fb3a34..735b3c3 100644 --- a/settings.py +++ b/settings.py @@ -1,7 +1,7 @@ # Django settings for djangogtd project. import sys, os -DEBUG = True +DEBUG = False TEMPLATE_DEBUG = DEBUG ROOT = os.path.abspath(os.path.dirname(__file__)) @@ -12,9 +12,10 @@ MANAGERS = ADMINS +STACKATO = 'VCAP_SERVICES' in os.environ ## Pull in CloudFoundry's production settings -if 'VCAP_SERVICES' in os.environ: +if STACKATO: import json vcap_services = json.loads(os.environ['VCAP_SERVICES']) # XXX: avoid hardcoding here @@ -117,6 +118,7 @@ 'django.contrib.admindocs', 'django.contrib.databrowse', 'django.contrib.humanize', + 'django.contrib.staticfiles', 'gtd', 'south', ) diff --git a/urls.py b/urls.py index 6a9dff8..eab5073 100755 --- a/urls.py +++ b/urls.py @@ -16,7 +16,7 @@ url(r'^$', lambda request: redirect('/gtd')), ) -if settings.DEBUG: +if settings.DEBUG or settings.STACKATO: from os.path import join, dirname, abspath urlpatterns += patterns('', url(r'^media/admin/(?P.*)$', 'django.views.static.serve',