Use {% with %} tag in Django HTML template
<p>I have a list of areas like this : </p>

<pre><code>areas  = ['Anaheim', 'Westminster', 'Brea'...]
</code></pre>

<p>I would like to display them in HTML as:</p>

<pre><code>&lt;option value="Anaheim(Orange)"&gt;Anaheim&lt;/option&gt;
&lt;option value="Westminster(Orange)"&gt;Westminster&lt;/option&gt;
&lt;option value="Brea(Orange)"&gt;Brea&lt;/option&gt;
</code></pre>

<p>So I try this: </p>

<pre><code>{%for area in areas%}
    {% with area|add:"(Orange)" as area_county%}
        &lt;option value="{{area_county}}"&gt;{{area}}&lt;/option&gt;
    {% endwith %}
{%endfor%}
</code></pre>

<p>But the output is this:</p>

<pre><code>&lt;option value=""&gt;Anaheim&lt;/option&gt;
&lt;option value=""&gt;Westminster&lt;/option&gt;
&lt;option value=""&gt;Brea&lt;/option&gt;
</code></pre>

<p>Where did I do wrong? </p>

<p>Thank you!</p>

<p>You could use <code>extends</code> instead of <code>with</code>:</p>

<pre><code>{% extends area|add:"(orange)" %} 
</code></pre>

python django-templates