Django Template Variables behave differently when inside tags?

Check this out

{% if protocol == 'Add-Item='|concat:room.id %}
    {% include "supplies/item-form.html" %}
{% endif %}

the include block never executes even when 'Add-Item='|concat:room.id is exactly the output of {{ protocol }}. It then implies that the protocolvariable in the if block condition is an object and not the output of protocol.__str__()

Is this the design because this almost drove me crazy for three days? I had to implement a protocol property to achieve the desired output.

example cmd property in protocol below outputs a string:

{% if protocol.cmd == 'Add-Item='|concat:room.id %}
    {% include "supplies/item-form.html" %}
{% endif %}

That is correct. You are not rendering a variable reference named protocol in this tag, you are accessing the object in the if tag.

This is a fundamental difference between rendering a variable using {{ protocol }}, which causes the __str__ function to be called, and referencing the protocol object in a tag - {% ... %}.