[Answer]-Rendering multiple lists to the django template

1👍

To Traverse both lists individually in template ,

extra_context = {}
extra_context['list1'] = ["['a',1,2,3]","['b',4,5,6]","['c',7,8,9]"]
extra_context['list2'] = ["[12-09-13,pass]","[8-05-12,fail]"]
return render_to_response(ex.html,extra_context)

And in your template :

{% for li in list1 %}
    {{li}}
{% endfor %}

{% for li in list2 %}
    {{li}}
{% endfor %}

0👍

You can access the different lists using the dot operator:

{% for li in t.0 %} // t.0 would be list1
{{li}}
{% endfor %}
{% for li in t.1 %} // t.1 would be list2
{{li}}
{% endfor %}
👤Terry

Leave a comment