Django -- Template tag in {% if %} block
You shouldn't use the double-bracket {{ }}
syntax within if
or ifequal
statements, you can simply access the variable there like you would in normal python:
{% if title == source %} ...{% endif %}
Sorry for comment in an old post but if you want to use an else if statement this will help you
{% if title == source %} Do This{% elif title == value %} Do This{% else %} Do This{% endif %}
For more info see Django Documentation
{% for source in sources %} <tr> <td>{{ source }}</td> <td> {% ifequal title source %} Just now! {% endifequal %} </td> </tr>{% endfor %} or{% for source in sources %} <tr> <td>{{ source }}</td> <td> {% if title == source %} Just now! {% endif %} </td> </tr> {% endfor %}