3👍
✅
Short answer: no, you can’t.
Long(er) answer:
In this case I’d create a method on the manager, and use either .extra(where='...')
(which would probably require DB-specific SQL code) or a combination of models.Q
objects on the Event
queryset.
class EventManager(models.Manager):
def day_range(self, start, end):
qs = self.get_queryset()
qs = qs.extra(where=["day(start_date) < %s and day(end_date) > %s"],
params=[start, end])
return qs
Edited: the where
arg had to be a sequence.
Source:stackexchange.com