Query datetime by today’s date in Django

I remember there being plans to add a __date field lookup to make this easier, but as it stands the “standard” way of doing it is

today_min = datetime.datetime.combine(datetime.date.today(), datetime.time.min)
today_max = datetime.datetime.combine(datetime.date.today(), datetime.time.max)
Invoice.objects.get(user=user, date__range=(today_min, today_max))

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)