11π
β
A couple of possibilities:
-
The .shift string has extra whitespace. Use this to double-check:
{% for watchinstance in watchinstance_list %} X{{ watchinstance.shift }}X {% endfor %}
-
The .shift attribute isnβt a string, but an object that stringifies to βDAYβ or βNIGHTβ. In that case, the variable substitution in
{{ watchinstance.shift }}
would look the same as a string, but the comparison in{% ifequal watchinstance.shift "DAY" %}
would fail.
π€Ned Batchelder
51π
So after searching Django docs for 2 hours, I finally found a way to make it work:
{% if watchinstance.shift|stringformat:"s" == "DAY" %}
π€Sir Conquer
Source:stackexchange.com