내 레이아웃에 따라 데이터를 표시하려면 dict 항목을 정렬하거나 html 테이블을 재구성해야합니다.특정 레이아웃을 만들기 위해 HTML 테이블 또는 사전 키 정렬
<table>
<tr>
<th>title</th>
<th>name</th>
<th>quantity</th>
<th>street 1</th>
<th>street 2</th>
<th>county</th>
<th>city</th>
<th>country</th>
<th>postal</th>
<th>shipping</th>
</tr>
{% for order in orders %}
<tr>
{% for key, value in order.items %}
<td>
{% if key == "title" %}
{{value}}
{% endif %}
{% if key == "name" %}
{{value}}
{% endif %}
{% if key == "quantity" %}
{{value}}
{% endif %}
{% if key == "street1" %}
{{value}}
{% endif %}
{% if key == "street2" %}
{{value}}
{% endif %}
{% if key == "county" %}
{{value}}
{% endif %}
{% if key == "city" %}
{{value}}
{% endif %}
{% if key == "country" %}
{{value}}
{% endif %}
{% if key == "postal" %}
{{value}}
{% endif %}
{% if key == "shipping" %}
{{value}}
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
</table>
주문은 dicts의 목록입니다.
사전의 항목이 더 이상 특정 순서가 아니기 때문에 각 사전 항목을 적절한 열에 어떻게 넣을 수 있습니까?
여전히 열 머리글이 표시 될 때이를 표시해야합니다. 왼쪽에서 오른쪽으로 - "제목"은 첫 번째, "이름"초 등입니다.
바로 지금 도시는 제목 아래에 표시되고 수량은 수량 등으로 표시됩니다.