Django -- Template tag in {% if %} block -
i have following dictionary passed render function, sources being list of strings , title being string potentially equal 1 of strings in sources:
{'title':title, 'sources':sources})
in html template i'd accomplish among lines of following:
{% source in sources %} <tr> <td>{{ source }}</td> <td> {% if title == {{ source }} %} now! {% endif %} </td> </tr> {% endfor %}
however, following block of text results in error:
templatesyntaxerror @ /admin/start/ not parse remainder: '{{' '{{'
...with {% if title == {{ source }} %}
being highlighted in red.
you shouldn't use double-bracket {{ }}
syntax within if
or ifequal
statements, can access variable there in normal python:
{% if title == source %} ... {% endif %}
Comments
Post a Comment