views:

173

answers:

1

Hi overflowers,

I am using django to create a web-application.

I have created a template in where I load a templatetag. In this templatetag i load another templatetag. From the template I pass context to the first templatetag, but the context is not available from the second templatetag (inside the first templatetag) - see below.

I hope this makes sense, and that one of you have the answer.

Thanks in advance

Regards

Kasper Gadensgaard


Template snippit:

{% load templatetags %}
{% some_tag argument %}

some_tag Templatetag:

{% load templatetags %}
{% some_other_tag another_argument %}

some_other_tag Templatetag: In this templatetag i am trying to access context to get user info i.e. using

request = context['request']
request.user
+1  A: 

Don't forget that the context to the subtemplate - and hence to the second template tag - is whatever is returned from the first template tag function. So you'll need to ensure that the request object is included in the dictionary you return there.

Daniel Roseman
That would work, but is there no other way, e.g. making the context accesible from global?
Kasper Gadensgaard