1👍
✅
Unfortunately, Django’s templates don’t support such syntax. You should put together a custom template filter:
# yourapp/templatetags/yourapp_tags.py:
from django import template
register = template.Library()
@register.filter
def at_index(array, index):
return array[index]
and use it like:
{% load yourapp_tags %}
{{ tab.urls|at_index:forloop.counter0 }}
0👍
You need to make an actual model that represents the data then the task becomes trivial
class YourModel(object):
titre = ''
liste = ''
url = ''
context[u'erreurs'] = {
'aa': [], # List of model
}
{% for idx, tab in erreurs.items %}
<ul>
{% for model in tab %}
{{ model.titre }}
{{ model.liste }}
{{ model.url }}
{% endfor %}
</ul>
{% endfor %}
- Django: Setting the from address on an email
- What is a better option to use django-highcharts package to render charts in template or regular ugly rendering in django?
- Getting error as "TypeError at /add_follow/1/ __init__() takes 1 positional argument but 2 were given"
Source:stackexchange.com