I have a nested dictionary (because I want to access it by key) agenda, but I need to access the values in a specified order, for k I’m using a list, and k2 are date strings in iso format. I’ve red that I must access the nested dict structure like this:
{% for k, a_dict in agenda.items %}
{{ k }}
{% for k2, v in a_dict.items %}
{{ k }}-{{ k2 }}-{{ v.attribute }}
{% endfor %}
{% endfor %}
But then I cannot seem to find a way to specify the order of the iteration. Is there any other two dimensional data structure accessible from a django template in a pre-specified order? Am I missing something obvious?
Thnx in advance,
pablete
The python dict not maintain order. You must use a data structure which mantains the order, Example: SortedDict