All,
In Template condition check,whats wrong with the following code,
selected_id and selected_sub are equal to 5 but still ifequal loop is not working..
<tr><td><p>Subjects:</td>
<td>
<select id="subjects" name="subje开发者_如何学Ccts" multiple="multiple">
{% for subject in subjects %}
<option value="{{subject.id}}" {% for selected_id in selected_sub %}{% ifequal subject.id selected_id %} {{ selected }} {% endifequal %} {% endfor %} >{{subject.subject}}</option>
{% endfor %}
</select>
</p></td></tr>
Thanks..........
Ok, sorry. What is the output you get?
selected
should have the value 'selected="selected"'
.
Change to {% with selected as 'selected="selected"' %}
and try again.
If, as you say, selected_id
and selected_sub
are equal to 5 then
for selected_id in selected_sub
will not work, since 5 is not iterable.
精彩评论