Python 在Django模板中使用重组

Python 在Django模板中使用重组,python,django,django-templates,Python,Django,Django Templates,我收到一个JSON对象,其中包含许多对象和对象列表等。其中一个列表中的年份列表如下: [{'Year': '2015', 'Status': 'NR', 'Month': 'Jan' {'Year': '2014', Status': '', 'Month': 'Jan'}, {'Year': '2015', 'Status': '',Month': 'Feb'}, {'Year': '2014', Status': '', 'Month': 'Feb'}, {'Year': '2015'

我收到一个JSON对象,其中包含许多对象和对象列表等。其中一个列表中的年份列表如下:

[{'Year': '2015', 'Status': 'NR', 'Month': 'Jan'
{'Year': '2014', Status': '', 'Month': 'Jan'}, 
{'Year': '2015', 'Status': '',Month': 'Feb'}, 
{'Year': '2014', Status': '', 'Month': 'Feb'}, 
{'Year': '2015', 'Status': '', Month': 'Sep'}, 
{'Year': '2014', 'Status': 'OK', 'Month': 'Sep'}, 
{'Year': '2015', 'Status': '', 'Month': 'Oct'}, 
{'Year': '2014', 'Status': 'OK', 'Month': 'Oct'}] 
我需要将此列表按年份分组,并根据年份显示月份。例如:

{"2015":[{"Month":"Jan", "Status":"NR"}, {"Month" : "Feb". "Status" :""}]
现在,我使用的代码并没有按照我希望的方式工作,而是根据月份数重复年份:

2015                                                
2014                                                
2015                                                
2014                                                
2015                                                
2014                                                
2015                                                
2014
代码如下:

{% regroup x.LstPaymentBehaviour by Year as yearList %} 
  {% for ym in yearList  %}
    <tr>
           <td><strong>{{ ym.grouper }}</strong></td>
    </tr>
  {% endfor %}
{%x.lstpaymentbehavior按年份重新组合为yearList%}
{年表%中ym的百分比}
{{ym.gropper}
{%endfor%}
我遗漏了什么?

文档:

重新分组
首先需要有序数据。如果同一年的所有项目都是连续的,那么您将获得所需的输出。因此,首先对输入数据进行排序

{% regroup x.LstPaymentBehaviour|dictsort:'Year' by Year as yearList %} 
文件:

重新分组
首先需要有序数据。如果同一年的所有项目都是连续的,那么您将获得所需的输出。因此,首先对输入数据进行排序

{% regroup x.LstPaymentBehaviour|dictsort:'Year' by Year as yearList %} 

你有什么错误吗?如果是,那么具体是什么?好的,那么你到底看到了什么?循环在运行吗?如果是,那么有多少次?JSON对象来自哪里?您是否收到任何错误?如果是,那么具体是什么?好的,那么你到底看到了什么?循环在运行吗?如果是,那么有多少次?JSON对象来自哪里?