django循环内循环不能在teamplates上打印

时间:2017-11-24 14:01:01

标签: django django-templates

我正在使用django框架和python2.7并且在模型中我收到以下值作为查询结果集 { "receivable": -90786.82, "payable": 8826.72, "receivable_aging": { "age5": 235114.91999999998, "age4": 235114.91999999998, "age3": 0, "age2": 0, "age1": 0, "range": [ {"age5": "overdue in 10 days"}, {"age1": "<30"}, {"age2": "30-60"}, {"age3": "60-90"}, {"age4": ">90"} ], "overdue": 235114.91999999998 } } 通过上面的结果集我想在django模板中显示如下 receivable_aging&gt;范围

>90 is has 0    #0 is from receivable_aging.age1 & >90 is from 
                #receivable_aging.range.age1
30-60 is has 0  #0 is from receivable_aging.age2 & 30-60 is from
                #receivable_aging.range.age1

我是新来的,我尝试了很多方法,但没有工作请帮我这个

我的尝试是,

{% for key, value in response_bills.receivable_aging.items reversed %}
                                <div class="invoice-box-content">
                            <span class="invoice-box-text">

                                31 - 60 Days
                            </span>

                            {% if key not in "age5,range,overdue" %}

                                    <span class="invoice-box-value">
                                <i class="fa fa-inr fa-black fa-4" aria-hidden="true"></i> {{ value }}
                            </span>

                            {% endif %}
                            </div>

                        {% endfor %}

0 个答案:

没有答案