带有几个inclusion_tag的django上下文

时间:2010-10-06 15:36:29

标签: django tags django-context

我对上下文有点问题。

我有一个包含标签的参数:

takes_context=True 

在这个包含标签的模板中,我要求另一个包含param的inclus_tag

takes_context = True

但是在最后一个include_tag上下文中是None。

我不知道为什么?

1 个答案:

答案 0 :(得分:2)

不要忘记第二个包含标记的上下文是从第一个包含标记返回的内容。如果您需要原始模板中的整个上下文,最好将其复制:

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