Present data from python dictionary to django template.?
问题 I have a dictionary data = {'sok': [ [1, 10] ], 'sao': [ [1, 10] ],'sok&sao':[ [2,20]] } How Can I (Loop trough Dictionary ) present My data as (HTML) table to Django template.?? This format that as table author qty Amount sok 1 10 sao 1 10 sok&sao 2 20 total 回答1: You can use the dict.items() method to get the dictionary elements: <table> <tr> <td>author</td> <td>qty</td> <td>Amount</td> </tr> {% for author, values in data.items %} <tr> <td>{{author}}</td> {% for v in values.0 %} <td>{{v}}<