0

I have a model class called Foo, with the following fields start and duration.

class Foo(models.Model):
    start = models.DateTimeField()
    duration = models.DurationField()

I want to filter all the entries from the Foo table by checking that the start plus duration is less than a certain time.

1 Answers1

0

You should be able to the this with F expressions

from django.db.models import F
Foo.objects.filter(duration__lt=yourTime - F('start'))

You may need to make use of timedelta. See more examples here

JensV
  • 3,997
  • 2
  • 19
  • 43