如何在Django模板代码中执行“或”操作?

时间:2010-02-03 21:48:25

标签: python django

{% if is_loggedin OR is_anonymous %}
test message
{% endif %}

2 个答案:

答案 0 :(得分:4)

{% if is_loggedin or is_anonymous %}
test message
{% endif %}

就像那样。

答案 1 :(得分:1)

  

如果标签可以使用和,或不测试多个变量或否定给定变量:

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#if

你这样做的方式很好。 : - )

相关问题