[Answer]-Django template: why variable name evaluate to string

1๐Ÿ‘

โœ…

You should remove quotes in lines:

{% with t=turl1 %}
{% with o=ourl1 %}

If you want to iterate over it, you should pass in two arrays from your view.

{'urls': [[turl1, ourl1], [turl2, ourl2]]}

Then iterate over it in your template:

{% for t, o in urls %}
     <a href="{{ o }}">
         <img src="{{ t }}"/>
     </a>
{% endfor %}
๐Ÿ‘คYossi

0๐Ÿ‘

If turl1, turl2...ourl1, ourl2 are context variables then in the django templates you need to put them between { ... }

Leave a comment