tags:

views:

81

answers:

2

I've found that link: http://code.djangoproject.com/attachment/ticket/8424/time_filters.diff and changed my django 1.2 files by adding taht what you can see there.
But now, when I'm trying to write Entry.objects.filter(pub_date__hour = x) - the result is following error:

Field has invalid lookup: hour

What should I do else, to make it work?

(sorry for my english)

A: 

Maybe you defined pub_date as a DateField, but it must be a DateTimeField? Can you include in the question your model definition code?

Euribates
yes - it is DateTimeField
DJPy
+1  A: 
Entry.objects.filter(pub_date__hour = x)

is not supported as of django 1.2 - only year, month, day, week_day.

Use something like this:

Entry.objects.filter(pub_date__regex = '08:00')

or

Entry.objects.filter(pub_date__contains = '08:00')

which will give you all Entry objects with the hour (over all years).

zovision