dates = [(1, '2009-01-01 10:15:23'), (2, '2009-01-01 13:21:29'), (3,
    '2009-01-02 01:03:13'), (4, '2009-01-03 12:20:19'), (5,
    '2009-01-03 13:01:06')]
for key, group in itertools.groupby(dates, key=lambda x: x[1][:11]):
    print(key)
for element in group:
    pass
Grouping dates in Django