title: Calculating averages in django models
body: <p>I need to find out the average amount of quantity of a customers orders. How would I do this using django's models?</p>
  
  <pre><code>from django.db import models
  
  class Customer(models.Model):
      name = models.CharField(max_length=200)
      phone = models.CharField(max_length=17)
      average_quantity_size = ?
  
  class Order(models.Model):
      customer = models.ForeignKey(Customer)
      quantity = models.PositiveSmallIntegerField()
      date = models.DateField()
      time = models.TimeField()
  </code></pre>