Reputation: 1556
I have a list of areas like this :
areas = ['Anaheim', 'Westminster', 'Brea'...]
I would like to display them in HTML as:
<option value="Anaheim(Orange)">Anaheim</option>
<option value="Westminster(Orange)">Westminster</option>
<option value="Brea(Orange)">Brea</option>
So I try this:
{%for area in areas%}
{% with area|add:"(Orange)" as area_county%}
<option value="{{area_county}}">{{area}}</option>
{% endwith %}
{%endfor%}
But the output is this:
<option value="">Anaheim</option>
<option value="">Westminster</option>
<option value="">Brea</option>
Where did I do wrong?
Thank you!
Upvotes: 1
Views: 103
Reputation: 305
Maybe if you try only put the text next to the template variable like:
{%for area in areas%}
<option value="{{area}}(Orange)">{{area}}</option>
{%endfor%}
I don't know why you try but is the same for me.
Upvotes: 2
Reputation: 3730
You could use extends
instead of with
:
{% extends area|add:"(orange)" %}
Upvotes: 1