开发者

django context with several inclusion_tag

开发者 https://www.devze.com 2023-01-18 19:37 出处:网络
I have a little problem with the context. I have an inclusion tag with the param : takes_context=True In this inclusion\'s tag\'s template, I call for another inclusion_tag whic开发者_如何学Goh h

I have a little problem with the context.

I have an inclusion tag with the param :

takes_context=True 

In this inclusion's tag's template, I call for another inclusion_tag whic开发者_如何学Goh has also the param

takes_context = True

But in this last inclusion_tag context is None.

I don't know why ?


Don't forget that the context for the second inclusion tag is whatever is returned from the first one. If you need the entire context from the original template, it's best to copy it over:

@register.inclusion_tag('template.html', takes_context=True)
def first_inclusion_tag(context, value):
    params = {'value': value}
    params.update(context)
    return params
0

精彩评论

暂无评论...
验证码 换一张
取 消