2👍
✅
Django doesn’t support filter methods like __lt
, __gt
, __in
on date field attributes. There’s a ticket about this #6439.
You can do the filter you want using extra
:
day = 2
Entry.objects.extra(where=["EXTRACT(day FROM from) <= %s"], params=[day])
I’ve tested the above with MySQL, the syntax may be different for other SQL backends.
Source:stackexchange.com