Is this by design or am I doing something wrong? Here is the situation:
I have this in template_A: {% if obj %}{% include template_B with thing=obj %}{% endif %}
and in template_B:
<div>{{ thing.name }}</div>
{% if thing.name == "text" %}<p> It is working!</p>{% endif %}
I find that thing.name evaluates in template_B and renders in the div but the paragraph block (<p></p>) does not render even when thing.name evaluates to "text". It appears passing objects between templates only work for {{ variables }} but not for {% tags %}
I think what the questioner is trying to convey is that the include template is not working properly.
Here’s what you need to check:
. What is the HTML that appears in the final rendering?
. Are individual apps using templates with the same name?
. Is {{ obj.name }} valid in the template a?
. Aren’t you overwriting {{ thing }} in template b?
What you show should work, so it seems like something else is going wrong. Not very helpful, but just wanted to confirm that it should work as you expect.
In addition to the excellent suggestion above, what isthing.name?
If thing.name is an object or a foreign key, it might render as “text”, but it is not== “text”. So knowing what these objects are is also important.