I use this code to form a dictionary:
tt_data[dt] = {}
for hour in range(work_begins, work_ends, 2):
tt_data[dt][hour] = ''
if Rehearsal.objects.filter(dt__year=dt.year, dt__month=dt.month, dt__day=dt.day, dt__hour=hour).exists():
tt_data[dt][hour] = Rehearsal.objects.get(dt__year=dt.year, dt__month=dt.month,
dt__day=dt.day, dt__hour=hour)
The strange thing is when "work_begins" equals 14, this element goes to the end of the dict:
Any help appreciated.