Model
class Session(models.Model):
start_time = models.DateTimeField()
end_time = models.DateTimeField()
def duration(self):
return self.end_time - self.start_time
Template
{{ session.duration|date:"H:i" }}
The duration can be displayed but seems not formattable. An idea why ?
In django templates you can use timesince and timeuntil filters for the same purpose. Both take two dates as an input and return the difference in a readable format.