I have 3 dictionaries data['d1'], data['d2'] and data['d3'].
What i want is the table to look like this, getting the keys from each dictionary and presenting them like:
Team 1 | Team 2 | Team 3
key 1 from d1 | key 1 from d2 | key 1 from d3
key 2 from d1 | key 2 from d2 | key 2 from d3
key 3 from d1 | key 3 from d2 | key 3 from d3
key 4 from d1 | key 4 from d2 | key 4 from d3
What i have tryed
<thead>
<tr>
<th>Team 1</th>
<th>Team 2</th>
<th>Team 3</th>
</tr>
</thead>
<tbody>
<tr>
{% for key, value in d1.items %}
<td>{{ key }}</td>
{% endfor %}
</tr>
<tr>
{% for key, value in d2.items %}
<td>{{ key }}</td>
{% endfor %}
</tr>
<tr>
{% for key, value in d3.items %}
<td>{{ key }}</td>
{% endfor %}
</tr>
</tbody>
or
<thead>
<tr>
<th>Team 1</th>
<th>Team 2</th>
<th>Team 3</th>
</tr>
</thead>
<tbody>
{% for key, value in d1.items %}
<tr>
<td>{{ key }}</td>
</tr>
{% endfor %}
{% for key, value in d2.items %}
<tr>
<td>{{ key }}</td>
</tr>
{% endfor %}
{% for key, value in d3.items %}
<tr>
<td>{{ key }}</td>
</tr>
{% endfor %}
</tbody>
but it's showing them differently. How can i achieve the above table?
Current table is displayed like this:
Stalone Sobont arda AAA
Sardina Jhonny Lala Vali
LilJon Scuipy SSS Mazare
views.py
stats = data['scoruri'].copy()
data['d1'] = {}
data['d2'] = {}
data['d3'] = {}
for key, value in stats.copy().items():
if not data['d1'] or sum(data['d1'].values()) <= sum(data['d2'].values()) and \
sum(data['d1'].values()) <= sum(data['d3'].values()):
name, score = max(stats.items(), key=lambda p: p[1])
data['d1'][name] = score
stats.pop(name, score)
data['total_1'] = sum(data['d1'].values())
elif not data['d2'] or sum(data['d2'].values()) <= sum(data['d1'].values()) and \
sum(data['d2'].values()) <= sum(data['d3'].values()):
name, score = max(stats.items(), key=lambda p: p[1])
data['d2'][name] = score
stats.pop(name, score)
data['total_2'] = sum(data['d2'].values())
elif not data['d3'] or sum(data['d3'].values()) <= sum(data['d1'].values()) and \
sum(data['d3'].values()) <= sum(data['d2'].values()):
name, score = max(stats.items(), key=lambda p: p[1])
data['d3'][name] = score
stats.pop(name, score)
data['total_3'] = sum(data['d3'].values())