I am populating a list in my view:
hits_object = {} hits_object['Studio'] = hitlist('Studio',days) hits_object['Film'] = hitlist('Film',days) hits_object['Actor'] = hitlist('Actor',days) hits_object['Historical Event'] = hitlist('Event',days) hits_object['Pop Culture'] = hitlist('Pop_Culture',days) Then I am displaying it in my template:
{% for model, hits in hits_object.items %} {% if hits %} <u> Most {{ model }} views in last {{ days }} days</u> <ol> {% for hit in hits %} <li>{{ hit.name }} - {{ hit.count }}</li> {% endfor %} </ol> </u> {% endif %} {% endfor %} The problem is that the models display in a seemingly random order: first Actor, then Studio, Historical Event, Film, etc.
How can I force the for loop in the template to iterate the object in a specific order?