tags:

views:

37

answers:

1

hay Guys, 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 im calling this with

{% load extras %}
{% show_side_bar %}

Thanks

+2  A: 

To have a request variable in your template context, the django.core.context_processors.request context processor needs to be in your TEMPLATE_CONTEXT_PROCESSORS setting. 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.)

LeafStorm
I've added the stuff to the settings file. I've added the context variable to my method. But the context var only holds a bunch of model objects.
dotty