Reputation: 6319
After I set a session object, how can I access the value of the given object in my templates?
Upvotes: 1
Views: 3154
Reputation:
Depending on how many session variables you have, it might be easier to just add the variable to the context dictionary.
Upvotes: 0
Reputation: 10896
{{request.session.variable}}
RequestContext will give you access to request object in templates.
You'll have to add this to your settings.py:
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request',
... )
And to hook up RequestContext to templates you can use this idiom in the view function:
from django.template import RequestContext
from django.shortcuts import render_to_response
return render_to_response('template.html', var_dict,\
context_instance=RequestContext(request))
Upvotes: 6