Skip to content Skip to sidebar Skip to footer

Django Template : Need 2 Values To Unpack In For Loop; Got Many

So to update my previous question : Django template : Need 2 values to unpack in for loop; got 8 from django.shortcuts import render, redirect from accounts.forms import Search

Solution 1:

In your template use

{% for i in annonces %}
    <h3>{{i.0}}</h3>
    <h3>{{i.1}}</h3>
    #and so on
    #..
    <h3>{{i.8}}</h3>
{% endfor %}

Solution 2:

There is two ways: First one:

{% for i in annonces %}
    <h3>{{i.0}}</h3>
    <h3>{{i.1}}</h3>
    #and so on
    #..
    <h3>{{i.7}}</h3>
{% endfor %}

Second one

{% for a,b,c,d,e,f,g,h in annonces %}
    <h3>{{a}}</h3>
    <h3>{{a}}</h3>
    #and so on
    #..
    <h3>{{h}}</h3>
{% endfor %}

Post a Comment for "Django Template : Need 2 Values To Unpack In For Loop; Got Many"