From 943ef2e8e436a32ce5dc956c4d855866cd644cc1 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 5 Dec 2011 23:06:10 -0600 Subject: Convert to and enable staticfiles contrib application This moves our site static files into the sitestatic directory if they are shared resources, and also moves a handful of things (such as the artwork logos) into application-specific static/ directories. This allows the staticfiles contrib app to work after a few settings tweaks, a run of collectstatic, and massaging the hardcoded '/media/' prefix out of our templates. Django 1.4 is going to make this a lot easier to move things to a CDN and provides better template tags; for now this is setting the stage before we can move to that. Signed-off-by: Dan McGee --- settings.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'settings.py') diff --git a/settings.py b/settings.py index b22b429..a898381 100644 --- a/settings.py +++ b/settings.py @@ -34,11 +34,6 @@ SITE_ID = 1 DATE_FORMAT = 'Y-m-d' DATETIME_FORMAT = 'Y-m-d H:i' -# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a -# trailing slash. -# Examples: "http://foo.com/media/", "/media/". -ADMIN_MEDIA_PREFIX = '/media/admin_media/' - # Login URL configuration LOGIN_URL = '/login/' LOGIN_REDIRECT_URL = '/' @@ -52,6 +47,7 @@ TEMPLATE_CONTEXT_PROCESSORS = ( 'django.core.context_processors.debug', 'django.core.context_processors.i18n', 'django.core.context_processors.media', + 'django.core.context_processors.static', 'django.contrib.messages.context_processors.messages', 'main.context_processors.secure', ) @@ -84,6 +80,17 @@ MIDDLEWARE_CLASSES = ( ROOT_URLCONF = 'urls' +# URL to serve static files +STATIC_URL = '/static/' + +# Location to collect static files +STATIC_ROOT = os.path.join(DEPLOY_PATH, 'collected_static') + +# Look for more static files in these locations +STATICFILES_DIRS = ( + os.path.join(DEPLOY_PATH, 'sitestatic'), +) + # Configure where messages should reside MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage' @@ -100,14 +107,16 @@ INSTALLED_APPS = ( 'django.contrib.sitemaps', 'django.contrib.admin', 'django.contrib.markup', - 'main', # contains shared models and libs + 'django.contrib.staticfiles', + 'south', + + 'main', 'mirrors', 'news', 'packages', 'todolists', 'devel', 'public', - 'south', # database migration support 'releng', 'visualize', ) -- cgit v1.2.3-24-g4f1b