[Answer]-Django error in filtering datetime field by date : Join on field X not permitted

1👍

Heads up, this should work as of Django 1.9.

Entry.objects.filter(pub_date__date=datetime.date(2005, 1, 1))
Entry.objects.filter(pub_date__date__gt=datetime.date(2005, 1, 1))

0👍

Use __contains instead of __date:

r = Record.objects.filter(time__contains = datetime.today().date())

UPDATE

Since that __startswith (LIKE ‘value%’) is more faster than __contains (LIKE ‘%value%’), the best choice is:

r = Record.objects.filter(time__startswith = datetime.today().date())

Leave a comment