別のチェックボックスの質問。私はリストに項目を持っています。各項目にはチェックボックスがあります。私がしたいのは、FIRSTの項目のチェックボックスをチェックすることです。それはchecked="checked"
のためにすべてのチェックボックスにチェックを入れました。ジャンゴ{% for %}
タグによって設定されたDjangoチェックボックスは、最初のボックスのみをチェックしたい
{% for item in items %}
<tr class="items_table_row">
<td><input type="checkbox" name="{{item.pk}}" value="{{item.pk}}" checked="checked"></td>
<td>{{item.tiptop_id}}</td><td>{{item.alternative_id}}</td><td>{{item.title}}</td><td>{{item.type}}</td><td>{{item.format}}</td>
<td><span id="{{item.pk}}" name="type">{{item.itemstatushistory_set.latest}}</span></td><td>{{item.itemstatushistory_set.latest.date.date|date:"d M Y"}}</td>
<td><a href="{% url tiptop.views.edit_item item.client.pk item.pk %}" onclick="return showAddAnotherPopup(this);">Edit</a></td>
</tr>
{% endfor %}
大丈夫です。これは私が探しているものです。 – Shehzad009
参考までに - Django 1.2(または1.1の場合もある)から、{%ifloal forloop.counter 2%}は{%if forloop.counter == 2%}として書き直すことができます。 –