1๐
You could use {% if forloop.first %}
to check if this is the first iteration.
A full list of forloop constructs can be found here:
https://docs.djangoproject.com/en/dev/ref/templates/builtins/#for
๐คIon Scerbatiuc
0๐
{{ forloop.counter }}
should give you the count of the iteration. If itโs one, you should be dealing with your first element.
๐คpypat
- [Answer]-Inline google stylsheet link to a div
- [Answer]-Image upload through admin in Django
- [Answer]-Django-extra-views and SortableListMixin configuration confusion
- [Answer]-Django post list json
- [Answer]-Django CSRF token missing or incorrect for FormView
0๐
you can add a custom css class for first element
{% for i in prosize %}
<li {% if forloop.first %}class="red"{% endif %}>
<a class="order" id="{{i.option1}}">{{i.option1}}</a>
</li>
{% endfor %}
and css
.red {
background: red;
}
๐คBenyasca
- [Answer]-Data not being shown when template is included in another template
- [Answer]-Twitter Bootstrap not displaying in Template
Source:stackexchange.com