Exact lookups on DateTimeField() with datetime.date object does not work
In http://www.djangoproject.com/documentation/db-api/ there are several examples of passing in datetime.date() objects (notice it's not a datetime.datetime() object) as lookup parameters on a DateTimeField()
. See http://www.djangoproject.com/documentation/db-api/#spanning-multi-valued-relationships for one such example:
Blog.objects.filter(entry__headline__contains='Lennon',
entry__pub_date=datetime.date.today())
The only way I've been able to get the intended behavior is through the use of the range lookup:
today = datetime.date(2008, 6, 26)
tomorrow = datetime.date(2005, 6, 27)
Blog.objects.filter(entry__headline__contains='Lennon',
entry__pub_date__range=(today, tomorrow))
I'm assuming this is just a documentation issue, rather than a query bug.
Change History
(6)
Triage Stage: |
Unreviewed → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
Speaking to the author of this documentation (Malcolm wishes to remain nameless), this is indeed a documentation bug. Patch to follow.