From: Brett Parker Date: Thu, 31 Jan 2008 13:56:29 +0000 (+0000) Subject: Update to use a context processor for the MEDIA_URL rather than having to pass it... X-Git-Url: https://git.sommitrealweird.co.uk/sommitrealweird.git/commitdiff_plain/d4b37caed377b2739b82a3ac6e002f008d2616bd Update to use a context processor for the MEDIA_URL rather than having to pass it in in each view --- diff --git a/sommitrealweird/content/views.py b/sommitrealweird/content/views.py index e4b49da..423e44f 100644 --- a/sommitrealweird/content/views.py +++ b/sommitrealweird/content/views.py @@ -1,7 +1,6 @@ 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: @@ -50,6 +49,5 @@ def document_view(request, slug=None, folders=None): { "content" : doc.content, "title" : doc.title, - "media_url" : MEDIA_URL, }) return HttpResponse(t.render(c)) diff --git a/sommitrealweird/generic/context_processors.py b/sommitrealweird/generic/context_processors.py new file mode 100644 index 0000000..d7ab9e0 --- /dev/null +++ b/sommitrealweird/generic/context_processors.py @@ -0,0 +1,6 @@ +from django.conf import settings + +def media(request): + return { + 'MEDIA_URL': settings.MEDIA_URL, + } diff --git a/sommitrealweird/settings.py b/sommitrealweird/settings.py index 280a04e..e81db68 100644 --- a/sommitrealweird/settings.py +++ b/sommitrealweird/settings.py @@ -84,3 +84,10 @@ INSTALLED_APPS = ( 'content', 'generic', ) + +TEMPLATE_CONTEXT_PROCESSORS = ( + 'django.core.context_processors.auth', + 'django.core.context_processors.debug', + 'django.core.context_processors.i18n', + 'generic.context_processors.media' +) diff --git a/templates/base.html b/templates/base.html index b471f8d..957d995 100644 --- a/templates/base.html +++ b/templates/base.html @@ -3,7 +3,7 @@ {% block title %}{{ title }}{% endblock %} - +