Django Template Ternary Operator

后端 未结 6 836
慢半拍i
慢半拍i 2020-12-29 19:32

I was wondering if there was a ternary operator (condition ? true-value : false-value) that could be used in a Django template. I see there is a python one (true-value if c

6条回答
  •  萌比男神i
    2020-12-29 20:06

    You don't. The Django {% if %} templatetag has only just started supporting ==, and, etc. {% if cond %}{% else %}{% endif %} is as compact as it gets for now.

提交回复
热议问题