Assume I have a such model:
class Entity(models.Model):
start_time = models.DateTimeField()
I want to regroup them as list of lists which each list of lists contains Entities from the same date (same day, time should be ignored).
How can this be achieved in a pythonic way ?
Thanks
Create a small function to extract just the date:
Then you can use it with
itertools.groupby:Or, if you really want a list of lists: