]> git.sommitrealweird.co.uk Git - sommitrealweird.git/commitdiff
Update to use a context processor for the MEDIA_URL rather than having to pass it...
authorBrett Parker <brettp@fudge.(none)>
Thu, 31 Jan 2008 13:56:29 +0000 (13:56 +0000)
committerBrett Parker <brettp@fudge.(none)>
Thu, 31 Jan 2008 13:56:29 +0000 (13:56 +0000)
sommitrealweird/content/views.py
sommitrealweird/generic/context_processors.py [new file with mode: 0644]
sommitrealweird/settings.py
templates/base.html

index e4b49da50eee581157666c792e724b20e7dd5f33..423e44fa51ed1b0f7b21477a1b56aef9d0fe5b12 100644 (file)
@@ -1,7 +1,6 @@
 from content.models import Document, Folder
 from django.http import Http404, HttpResponse
 from django.template import RequestContext, loader
 from content.models import Document, Folder
 from django.http import Http404, HttpResponse
 from django.template import RequestContext, loader
-from settings import MEDIA_URL
 
 def document_view(request, slug=None, folders=None):
     if folders == None and slug == None:
 
 def document_view(request, slug=None, folders=None):
     if folders == None and slug == None:
@@ -50,6 +49,5 @@ def document_view(request, slug=None, folders=None):
         {
             "content"   : doc.content,
             "title"     : doc.title,
         {
             "content"   : doc.content,
             "title"     : doc.title,
-            "media_url" : MEDIA_URL,
         })
     return HttpResponse(t.render(c))
         })
     return HttpResponse(t.render(c))
diff --git a/sommitrealweird/generic/context_processors.py b/sommitrealweird/generic/context_processors.py
new file mode 100644 (file)
index 0000000..d7ab9e0
--- /dev/null
@@ -0,0 +1,6 @@
+from django.conf import settings
+
+def media(request):
+    return {
+        'MEDIA_URL': settings.MEDIA_URL,
+    }
index 280a04e8fad7dc95adb3635bbf4bda7a5d9f9d4b..e81db68001ae744ceb48a117b32676fa6d1e2f4a 100644 (file)
@@ -84,3 +84,10 @@ INSTALLED_APPS = (
     'content',
     'generic',
 )
     'content',
     'generic',
 )
+
+TEMPLATE_CONTEXT_PROCESSORS = (
+    'django.core.context_processors.auth',
+    'django.core.context_processors.debug',
+    'django.core.context_processors.i18n',
+    'generic.context_processors.media'
+)
index b471f8d44bd65c5f04509270b51fb5c40daf753e..957d995a225d6ddb96c6fe1e131a7de8982d7e2a 100644 (file)
@@ -3,7 +3,7 @@
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
     <head>
         <title>{% block title %}{{ title }}{% endblock %}</title>
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
     <head>
         <title>{% block title %}{{ title }}{% endblock %}</title>
-        <link rel="stylesheet" type="text/css" href="{{ media_url }}style/main.css" />
+        <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}style/main.css" />
     </head>
     <body>
         <div id="page">
     </head>
     <body>
         <div id="page">