Django — Template tag in {% if %} block

前端 未结 4 377
花落未央
花落未央 2020-12-16 08:51

I have the following dictionary passed to a render function, with sources being a list of strings and title being a string potentially equal to one of the strings in sources

4条回答
  •  星月不相逢
    2020-12-16 09:42

    Sorry for comment in an old post but if you want to use an else if statement this will help you

    {% if title == source %}
        Do This
    {% elif title == value %}
        Do This
    {% else %}
        Do This
    {% endif %}
    

    For more info see Django Documentation

提交回复
热议问题