Django 模板标记如果

Django 模板标记如果,django,Django,我得到两个变量: post = Post.objects.get(pk=post_id) rated = Rated.objects.filter(username=request.user,rated=True) 由django mptt magicpost.comment\u root.get\u substands转换为节点 在模板中,我尝试使用: {% if node in rated %} X {% else %} Y {% endif %} ,但总是会感到不安。为

我得到两个变量:

post = Post.objects.get(pk=post_id)
rated = Rated.objects.filter(username=request.user,rated=True)
由django mptt magic
post.comment\u root.get\u substands
转换为
节点

在模板中,我尝试使用:

{% if node in rated %}
    X
{% else %}
    Y
{% endif %}
,但总是会感到不安。为什么


附言:对不起我的英语

我猜是
post.comment\u root.get\u subjections
为你提供了一个
comment
S的查询集。
注释
永远不会出现在
分级
的查询集中,因为它们是不同类型的。您需要将苹果与苹果进行比较。

发布“额定”和“节点”的示例值