Compare date and datetime in Django
问题 I have a model with a datetime field: class MyModel(models.Model): created = models.DateTimeField(auto_now = True) I want to get all the records created today. I tried: MyModel.objects.all().filter(created = timezone.now()) and MyModel.objects.all().filter(created = timezone.now().date()) But always got an empty set. What is the correct way in Django to do this? EDIT: It looks strange, but a record, created today (06.04.2012 23:09:44) has date (2012-04-07 04:09:44) in the database. When I'm