I read it
"DJANGO.CORE.CONTEXT_PROCESSORS.REQUEST If TEMPLATE_CONTEXT_PROCESSORS contains this processor, each RequestContext will contain a variable request that is the current HttpRequest. Note that this processor is not enabled by default; you will have to activate it." From this page
http://docs.djangoproject.com/en/dev/ref/templates/api/
But there seems to be no information on how to activate this processor.
Here is my original question
Access request in django template custom tags
After I completed the answer
I still got errors
TemplateSyntaxError at / Caught an exception while rendering: 'request' Original Traceback (most recent call last): File "C:\Python25\lib\site-packages\django\template\debug.py", line 71, in render_node result = node.render(context) File "C:\Python25\lib\site-packages\django\template__init__.py", line 936, in render dict = func(*args) File "c:\...\myapp_extras.py", line 7, in login request = context['request'] File "C:\Python25\lib\site-packages\django\template\context.py", line 44, in getitem raise KeyError(key) KeyError: 'request'
code causing problem
request = context ['request'] in
from django import template register = template.Library() @register.inclusion_tag('userinfo.html',takes_context = True) def userinfo(context): request = context['request'] address = request.session['address'] return {'address':address}
source share