I have this model:
class TimeInterval(models.Model):
startTime = models.DateTimeField()
endTime = models.DateTimeField()
How can I aggregate average time interval using only the QuerySet API?
I tried this:
qs = TimeInterval.objects.extra(
select={"duration": "endTime - startTime"}).aggregate(
Avg("duration"))
but it throws:
FieldError: Cannot resolve keyword 'duration' into field. Choices are:
endTime, startTime