[Answered ]-Filter combined date and time in django

2👍

Lookup using Q objects:

from django.db.models import Q

today = datetime.now().date()
now = datetime.now().time()

future_events = CauseEvent.objects.filter(cause=instance) \
                                  .exclude(Q(date__lt=today) |
                                           Q(date=today, time__lt=now))

Leave a comment