I'm building a web app using Django. One of my models is this:
class Change(models.Model):
user=models.ForeignKey(User)
project=models.ForeignKey('Project')
starttime=models.DateTimeField(null=True,blank=True)
endtime=models.DateTimeField(null=True, blank=True)
worktime=models.FloatField(null=True, blank=True)#worktime is in hours
comment=models.CharField(max_length=500)
flagged=models.BooleanField(default=False, db_index=True)
As you can see the starttime
and endtime
are datetime
objects. I want to run a sql query grouping the results by date. But since the objects are datetime
, they are grouped by date and time. Is it possible? I looked at both Python and Django docs without find anything useful. Thank you.