开发者

django context with several inclusion_tag

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜