title: Calculating average age in Django
body: <p>I need to find out average age of items (groupped by various criteria, but it does not seem to be the issue). However I fail to find how to effectively create aggregation over DateTimeField using Django (on top of MySQL).</p>
  
  <p>Pure <code>Item.objects.all.aggregate(Avg('created'))</code> seems to produce absolutely bogus values (eg. 20081988007238.133) and using <code>Item.objects.all.extra(...)</code>  I have not found a way how to aggregate.</p>
  
  <p>Of course I can manually create SQL query (something like <code>SELECT AVG(UNIX_TIMESTAMP(created)) FROM items_item</code>), but I'd prefer to avoid using MySQL specific code in the application.</p>
  
  <p>Just for the reference, sample model I use for testing:</p>
  
  <pre><code>class Item(models.Model):
      name = models.CharField(max_length = 255)
      created = models.DateTimeField()
  </code></pre>