6

私は辞書を持っています:

field = 

{
   u'Birthday:': [datetime.date(2012, 4, 6), datetime.date(2012, 4, 27)],
   u'Education': [u'A1', u'A2'],
   u'Job:': [u'job1', u'job2'],
   u'Child Sex:': [u'M', u'F']
}

私のテンプレートコードは次のとおりです。

<table width="100%" border="0">
     <tr>
        {% for k, v in field.items %}
            <th>{{ k }}</th>
        {% endfor %}
     </tr>
     <tr>
       {% for k,v in field.items %}
            <td>
                <table width="100%" border="0">
                 {% for a in v %}
                     <tr class="{% cycle 'odd' 'even' %}"><td>{{ a }}</td></tr>
                 {% endfor %}
                </table>
            </td>
        {% endfor %}
     </tr>
</table>

辞書のキーをテーブルのヘッダーとして表示し、値を行として表示したい:

Birthday                          Education      Job        Child Sex
datetime.date(2012, 4, 6)         A1             job1       M
datetime.date(2012, 4, 27)        A2             job2       F

しかし、2 番目のテーブルを挿入する必要があります。辞書のキーをテーブルのヘッダーとして表示し、値を行として表示する方法はありますか?

前もって感謝します

4

2 に答える 2