* Add "static" context processor that puts STATIC_URL_PREFIX in the context.
authorMatthijs Kooijman <matthijs@stdin.nl>
Thu, 24 Jan 2008 11:46:40 +0000 (12:46 +0100)
committerMatthijs Kooijman <matthijs@stdin.nl>
Thu, 24 Jan 2008 11:46:40 +0000 (12:46 +0100)
 * Add STATIC_URL_PREFIX to settings.

settings.py
tools/context_processors.py [new file with mode: 0644]

index 7d91bf193d1b2c1ef63d59c7910bdb1d1b5926d8..d6b5299bb279839b7a178499df35ef512461f5ac 100644 (file)
@@ -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 (file)
index 0000000..b0d0282
--- /dev/null
@@ -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}