Present data from python dictionary to django template.?

后端 未结 3 984
粉色の甜心
粉色の甜心 2021-02-04 08:08

I have a dictionary

data = {\'sok\': [ [1, 10] ], \'sao\': [ [1, 10] ],\'sok&sao\':[ [2,20]] }

How Can I (Loop trough Dictionary ) pres

3条回答
  •  清歌不尽
    2021-02-04 08:52

    Unfortunately, django templates do not deal with Python tuples. So it is not legal to use "for author, values" in the template. Instead, you must access tuple or array values by their index by using ".index", as in "tuple.0" and "tuple.1".

    
    
        {% for entry in data.items %}
        
            {% for v in entry.1 %}
            
            {% endfor %}
        
        {% endfor %}
    
    author qty Amount
    {{entry.0}}{{v}}

提交回复
热议问题