Short django if-else template

I would like to know if there is a way to do a short if-else in a django template, e.g. in php?

  <?=$variable ? 'String for true' : 'String for false'?>

If the value of the variable is true, display String for trueotherwiseString for false

+5
source share
1 answer

There is a yesno template filter that displays values ​​for true, false.

{{ variable|yesno:'String for true,String for false' }}
+13
source

All Articles