Sum in html template using template tag

后端 未结 2 1960
萌比男神i
萌比男神i 2020-12-21 16:36

I am trying to sum in HTML,but template tag return 0 ,

View.py

def gen_Report(request):

### query returns below output 
list=[{\'total\': 1744, \'us         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-21 16:54

    I suspect that your list is an iterator. So the first time it iterates over and the second time it iterate over nothing. So you should do something like this

    for d in list_total:
       d.set('list_sum', list(d.get('list_sum')))
    

    before calling your template

提交回复
热议问题