I am working on creating a contract model with Django and I came cross on how to get the time duration from the start_date to the end_date??
class Contract(models.Model):
name = models.CharField(max_length=100)
price = models.IntegerField(max_length=10)
start_date = models.DateField(auto_now_add=True)
end_date = models.DateField(auto_now_add=True)
duration = models.IntegerField(end_date - start_date) # how get the duration by hours
created_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.name