views:

101

answers:

1

After I set a session object, how can I access the value of the given object in my templates?

+2  A: 

{{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))
Evgeny
OK...thanks so much. RequestContext will definately be required to access the request object...I had the same problem yesterday
Stephen