title: How to calculate the duration using startTime & endTime fields in a QuerySet in Django?
body: <p>I have this model:</p>
  
  <pre><code>class TimeInterval(models.Model):
      startTime = models.DateTimeField()
      endTime = models.DateTimeField()
  </code></pre>
  
  <p>How can I aggregate average time interval using only the QuerySet API?</p>
  
  <p>I tried this:</p>
  
  <pre><code>qs = TimeInterval.objects.extra(
      select={"duration": "endTime - startTime"}).aggregate(
          Avg("duration"))
  </code></pre>
  
  <p>but it throws:</p>
  
  <pre><code>FieldError: Cannot resolve keyword 'duration' into field. Choices are:
  endTime, startTime
  </code></pre>