1👍
✅
You could add the checked property to the second item as such:
{% ifequal forloop.counter 2 %} checked="checked"{% endifequal %}
The default forloop.counter
is 1-indexed, or you can specifically use a 0-indexed counter:
forloop.counter0
1👍
The forloop
variable set by the Django {% for %}
tag is your friend here.
Pop this in:
{% if forloop.first %} checked="checked"{% endif %}
i.e.
{% for item in items %}
<tr class="items_table_row">
<td><input type="checkbox" name="{{item.pk}}" value="{{item.pk}}"{% if forloop.first %} checked="checked"{% endif %}></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 %}
- [Answered ]-Pip is rolling back uninstall of setuptools
- [Answered ]-Django DetailView with form for comments
- [Answered ]-Emailing to new top-level domains (TLDs) in django
- [Answered ]-Querying a second model with django haystack
Source:stackexchange.com