ich bekomme es aktuell einfach nicht hin, dass ich mein Dictionary flexibel in eine bestimmte Form der Tabelle gerendert bekomme.
Das ist das beispielhafte Dictionary
Code: Alles auswählen
tolles_dict={"Standort1":{"url":"http://standort1", "id": "1", "parameter1": "value_param1_standort1", "parameter2": "value_param2_standort1",...,"parameterx": "value_paramx_standort1"},
"Standort2":{"url":"http://standort1", "id": "2", "parameter2": "value_param1_standort2", "parameter2": "value_param2_standort2",...,"parameterx": "value_paramx_standort2"},....,
"Standortx":{"url":"http://standort1", "id": "1", "parameter1": "value_param1_standortx", "parameter2": "value_param2_standortx",...,"parameterx": "value_paramx_standortx"}
}
Code: Alles auswählen
<html>
<table border="1">
<tr>
<td></td>
<td>Standort1</td>
<td>Standort2</td>
<td>...</td>
<td>Standortx</td>
</tr>
<tr>
<td>url</td>
<td>http://standort1</td>
<td>http://standort2</td>
<td>...</td>
<td>http://standortx</td>
</tr>
<tr>
<td>id</td>
<td>1</td>
<td>2</td>
<td>...</td>
<td>x</td>
</tr>
<tr>
<td>parameter1</td>
<td>value_param1_standort1</td>
<td>value_param1_standort2</td>
<td>...</td>
<td>value_param1_standortx</td>
</tr>
<tr>
<td>parameter2</td>
<td>value_param2_standort1</td>
<td>value_param2_standort2</td>
<td>...</td>
<td>value_param2_standortx</td>
</tr>
<tr>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
</tr>
<tr>
<td>parameterx</td>
<td>value_paramx_standort2</td>
<td>value_paramx_standort2</td>
<td>...</td>
<td>value_paramx_standortx
</tr>
</table>
</html>
Code: Alles auswählen
<tr>
<td></td>
{% for standort in tolles_dict %}
<td>{{ standort }}</td>
{% endfor %}
</tr>
{% for standort_name, standort_values in tolles_dict.items %}
{% for key, value in standort_values.items %}
<tr>
<td>{{ key }}</td>
{% for standort_name, standort_kvalues in tolles_dict.items %}
<td>{{ value }}</td>
{% endfor %}
</tr>
{% endfor %}
{% endfor %}
Es wird also statt value_param1_standort2 für den Standort2 der value_param1_standort1 geschrieben.
Ich komme hierbei irgendwie nicht weiter. Ich nehme an, dass die Lösung sehr einfach ist. Aber der Knoten im Kopf platzt aktuell einfach nicht

VG niesel