Given the following Contribution
model:
class Contribution(models.Model):
start_time = models.DateTimeField()
end_time = models.DateTimeField(null=True)
is it possible, using the Django database API, to reproduce the following SQL statement?
SELECT SUM(end_time - start_time) AS total_duration FROM contribution;
I've figured out this much:
Contribution.objects.aggregate(total_duration=models.Sum( ??? ))
but I'm not sure about how to represent the end_time - start_time
part. Thanks!