Python Django模板字典的显示顺序错误

Python Django模板字典的显示顺序错误,python,django,templates,Python,Django,Templates,我有一本字典。变量名称为分区\总计\显示 {87L: {'name': , 'total': 660L, 'total_percentage': 39, 'total_right': 256L}, 88L: {'name': , 'total': 660L, 'total_percentage': 42, 'total_right': 274L}, 89L: {'name': , 'total'

我有一本字典。变量名称为分区\总计\显示

{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}} 但是在模板中,当我打印{{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': }} {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开头,然后是88和89。

试着用一个。常规python字典是无序的——它们是使用哈希表实现的,哈希表会扰乱键顺序

根据:“最好将字典视为一组无序的键:值对,要求键是唯一的(在一个字典中)。”

尝试使用一个。常规python字典是无序的——它们是使用哈希表实现的,哈希表会扰乱键顺序


根据:“最好将字典视为一组无序的键:值对,要求键是唯一的(在一个字典中)。”

字典是无序的。改用嵌套列表。

字典是无序的。改用嵌套列表。

Great OrderDict似乎很有用。Great OrderDict似乎很有用。 {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': }}