Django template with nested loop rendering HTML table horizontally (vertically needed)

As the title says I need a HTML in a Django template rendering vertically. View code:

data = {
    "id": id,
    "name": name,
    "country": country
}

context = {
    "data": data,
}

HTML_STRING = render_to_string("home-view.html", context=context)

Template code:

<table>
    <thead>
        <tr>
            <th>#</th>
            <th>name</th>
            <th>country</th>
        </tr>
    </thead>
    <tbody>
        {% for key, values in data.items %}
            {% for v in values %}
                <tr>
                    <td>{{ v }}</td>
                </tr>
            {% endfor %}
        {% endfor %}
    </tbody>
</table>

This code renders this table:

id name country
1 2 3
Ioan Juan John
Romania Spain UK

What I need:

id name country
1 Ioan Romania
2 Juan Spain
3 John UK

What am I doing wrong? Can someone help me pls

Back to Top