我有一本以下字典。变量名是division_total_displayDjango模板字典显示顺序错误
{87L: {'name': , 'total': 660L, 'total_percentage': 39, 'total_right': 256L}, 88L: {'name': , 'total': 660L, 'total_percentage': 42, 'total_right': 274L}, 89L: {'name': , 'total': 435L, 'total_percentage': 34, 'total_right': 148L}}
我传递给模板如下:
return render_to_response('site/report_topic_standard_stat.html',
{
'report_date' : report_date,
'et_display' : et_display,
'stats_display' : stats_display,
'division_total_display' : division_total_display,
'school' : school,
'board' : board,
'standard' : standard,
'standard' : standard,
'subject' : subject,
'from_time' : from_time,
'term_id' : term_id,
'white_label' : white_label,
},
context_instance=RequestContext(request)
然而,在当我打印模板{{division_total_display}}
{88L: {'total_right': 274L, 'total': 660L, 'total_percentage': 42, 'name': }, 89L: {'total_right': 148L, 'total': 435L, 'total_percentage': 34, 'name': }, 87L: {'total_right': 256L, 'total': 660L, 'total_percentage': 39, 'name': }}
请注意顺序: - 其开始与88而不是87.
我希望它开始87跟随d除以88和89.
Great OrderDict似乎很有用。 –