I have a model similar to this one:
class Trip(models.Model):
departure = models.DateTimeField()
arrival = models.DateTimeField()
And I want to make a query that returns objects where the arrival is at least 2 hours later than the departure.
Trip.objects.filter(arrival__gt = "departure" + timedelta(hours=2))
Is this even possible? thanks
You are looking for filters that reference fields ont the model
See this sample:
For your case: