Is there a method that I cannot find to get individual hours in a DateTimeField? I essentially want the same thing as .dates (), but for hours.
I have to clarify what I'm talking about the QuerySet method. The date () method I'm talking about is here:
http://docs.djangoproject.com/en/1.1/ref/models/querysets/#dates-field-kind-order-asc
If not, is there a recommended known solution?
Thank.
Addendum for clarification: I have a model called Event with DateTimeField called start_date. We need to know what hours of a certain day have an event. Say we shorten it to a specific month:
objects = Event.objects.filter(start_date__year=2010, start_date__month=2)
Now the date functions can give me a list of all the days in which there is an event:
distinct_days = objects.dates('start_date', 'day')
What I would like is to narrow it down to a certain day, and then get a report list of hours of the day in which there is an event.
objects = Event.objects.filter(start_date__year=2010, start_date__month=2, start_date__day=3)
distinct_hours = objects.times('start_date', 'hour')
Thank.
mhost source
share