What is the optimal query to obtain all the records for one specific day? In my Weather model, ‘timestamp’ is a standard DateTimeField.
I’m currently using
start = datetime.datetime(2009, 1, 31) end = start + datetime.timedelta(hours=23, minutes=59, seconds=59) Weather.objects.filter(timestamp__range=(start, end))
but wonder if there is a more efficient method.
The way it’s done in django.views.generic.date_based is:
There should soon be a patch merged into Django that will provide a __date lookup for exactly this type of query (http://code.djangoproject.com/ticket/9596).