[Answered ]-Using multiple for tags in tables with django

2👍

✅

The inner loop should use the outer loop variable:

{% for x in result.netIncomeAr %}
    {% for y in x.d2 %} 

UPD (after looking at the result variable):

You need to change the result variable passed into the template, use zip() to join two lists:

result = zip(df['Date'], df['Net Income'])
return render_to_response('ui/search.html', {"result": result},  context)

Then, in the template iterate over the result this way:

<table>
    {% for x in result %}
    <tr>    
        <td>{{ x.0 }}</td>
        <td>{{ x.1 }}</td>
    </tr>
    {% endfor %}
</table>

Leave a comment