[Fixed]-How to use the current index to get the value of another array?

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 %}
👤Sayse

Leave a comment