Gets the list element at the given index
Example
{% for item1 in list1 %}
<p>List1 element: {{ item1 }}</p>
<p>List2 element: {{ list2|get_at_index:forloop.counter0 }}
{% endfor %}
1 2 3 4 5 6 7 | from django import template
register = template.Library()
@register.filter
def get_at_index(list, index):
return list[index]
|
More like this
- find even number by Rajeev529 2 weeks, 1 day ago
- Form field with fixed value by roam 1 month ago
- New Snippet! by Antoliny0919 1 month, 1 week ago
- Add Toggle Switch Widget to Django Forms by OgliariNatan 4 months ago
- get_object_or_none by azwdevops 7 months, 3 weeks ago
Comments
I found your question and answer on StackOverFlow and ended up here accordingly. THANK YOU VERY MUCH! (translated with Google Translate). Для русскоязычных постскриптум: регистрация здесь просто пи*дец.
#
Please login first before commenting.