Blog Archive for January 17, 2010

Iterating Dictionaries in Django Templates

January 17, 2010

You can access both the key and value parts of a python dictionary directly from django templates.

Create Dictionary

This code builds up a dictionary of contest names to number of events.

for row in rows:
    lContestName = row[2]
    try:
        lCountAlready = lResults[lContestName …