Sat 15 Jul 2006
Referencing “request” in Django templates
Posted by dkaz under Python, Programming
Django was kicking my ass tonight, as I struggled to figure out how to reference HttpRequest parameters in templates. It’s 2:00AM and I finally arrived at an answer - default TEMPLATE_CONTEXT_PROCESSORS in settings.py is missing “django.core.context_processors.request”. You can override the settings by explicitly setting it in settings.py:
TEMPLATE_CONTEXT_PROCESSORS = (
“django.core.context_processors.auth”,
“django.core.context_processors.debug”,
“django.core.context_processors.i18n”,
“django.core.context_processors.request”,
)
Above settings change enables HttpRequest by this function in the context_processor.py:
def request(request):
return {’request’: request}

July 15th, 2006 at 12:53 pm
how do you django so far? vs rails?
July 15th, 2006 at 1:34 pm
I’m a big fan of it so far, especially for a content-driven site.
Drawbacks right now are that the documentation is a bit sparse and you’re pretty much forced to keep up-to-date with Django’s Subversion trunk line.