开发者

Django template-printing variables

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜