我写了这个模板包含标签:
@register.inclusion_tag('blog/post_detail.html')
def post_detail(post, show_meta=True):
return {
'post': post,
'show_meta': show_meta
}
我这样称呼它:
{% post_detail post show_meta=False %}
这工作得很好。模板正确呈现,show_meta值为False.
但是,如果我将默认值更改为show_meta这样False:
def post_detail(post, show_meta=False):
然后,如果我尝试使用 调用它{% post_detail post show_meta=True %},模板仍然呈现为show_meta具有False. 为什么?