Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Is there a way to implement conditional OR inside templates? {% if %} would see if true or not...but what i'm looking for is to implement smthing when {% if %} OR {% if %}..thanks

question from:https://stackoverflow.com/questions/4555898/or-condition-in-django-templates

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
260 views
Welcome To Ask or Share your Answers For Others

1 Answer

in Django 1.2, you can use OR inside an IF tag...see the built-in template tags

{% if var1 == 'val1' or var2 == 'val2' %}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...