{% if user.is_authenticate %} {% if user in group1 %} group1 page {% elif user in group2 %} group2 page {% elif user in group3 %} group3 page {% endif %} {% else %} anonymous user page {% endif %}
In [23]: compile_string("""{% if user.is_authenticate %} {% if user in group1 %} group1 page {% elif user in group2 %} group2 page {% elif user in group3 %} group3 page {% endif %} {% else %} anonymous user page {% endif %}""", '') Out[23]: [<IfNode>]
@luoyou1014 是 1.4 以后支持 elif ,以前只能写 {% if A %} {% else %} {% if B %} {% else %} {% if C %} {% else %},每次要多写几个 else,1.4 之后把 else 和 if 缩写成 elif 了,(lazy man's suggestion i think :-)