I cannot seem to access request.sessions inside my inclusion template. Any ideas how I can get this data? The sessions are my own, custom ones.
My inclusion looks like
@register.inclusion_tag('base/side_bar.html', takes_context=True)
def show_side_bar(context):
models = Model.objects.all()
makes = Make.objects.all()
request = context['request']
return {
'makes':makes,
'models':models,
}
This errors out and says
Caught an exception while rendering: ‘request’
And I’m calling this with
{% load extras %}
{% show_side_bar %}
To have a
requestvariable in your template context, thedjango.core.context_processors.requestcontext processor needs to be in yourTEMPLATE_CONTEXT_PROCESSORSsetting. The trick is, it’s not there by default. You need to add it to your settings if you want to get it from the context like that. (See http://docs.djangoproject.com/en/1.1/ref/templates/api/#id1 for more information about context processors.)