In my Django project I need to calculate a date range for a trip to see if the trip is currently on its way.
class TourTemplate(models.Model):
length = models.IntegerField()
description = models.TextField(max_length=1000)
...
class Trip(models.Model):
tourtemplate = models.ForeignKey(TourTemplate)
start = models.DateField()
...
I added this to my Trip model:
def end(self):
length = self.tourtemplate.length
start = self.start
a = start + timedelta(days=length)
return a
In the shell it works and returns the end date for single objects. But how can I filter my queryset so that I only get objects between start and the calculated end date?