From: Matthijs Kooijman Date: Thu, 24 Jan 2008 11:46:40 +0000 (+0100) Subject: * Add "static" context processor that puts STATIC_URL_PREFIX in the context. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=0e722293e2baa147a70fe5c2c0d686e7abc1fba2;p=matthijs%2Fprojects%2Fxerxes.git * Add "static" context processor that puts STATIC_URL_PREFIX in the context. * Add STATIC_URL_PREFIX to settings. --- diff --git a/settings.py b/settings.py index 7d91bf1..d6b5299 100644 --- a/settings.py +++ b/settings.py @@ -43,6 +43,10 @@ MEDIA_ROOT = '' # Example: "http://media.lawrence.com" MEDIA_URL = '' +# URL prefix for static files. Will be made available by +# ee.tools.context_processors.static +STATIC_URL_PREFIX = '/static/' + # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a # trailing slash. # Examples: "http://foo.com/media/", "/media/". @@ -89,6 +93,8 @@ TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", + # Add STATIC_URL_PREFIX to the context + "ee.tools.context_processors.static", ) LOGIN_URL = "/accounts/login/" diff --git a/tools/context_processors.py b/tools/context_processors.py new file mode 100644 index 0000000..b0d0282 --- /dev/null +++ b/tools/context_processors.py @@ -0,0 +1,12 @@ +from django.conf import settings + +""" +Some useful context processors. +""" +def static(request): + """ + Adds url of static files to the context. + Requires STATIC_URL to be set in the settings. + + """ + return {'STATIC_URL_PREFIX': settings.STATIC_URL_PREFIX}