for i in arch:
    year = i.year
month = i.month
try:
    archives[year][month - 1][1] = True
except KeyError:
    archives[year] = [[date(y, m, 1), False] for m in range(1, 13)]
archives[year][month - 1][1] = True
return render_to_response('blog/arhiva.html', {'archives': sorted(list(archives.
    items()), reverse=True)})
Django Year/Month based posts archive