title: Getting result grouped by month in Django
body: <p>I want to get all members from a Member model and get total calculations that they have done per month.</p>
  
  <p>My query is as follows:</p>
  
  <pre><code>members_list = Member.objects\
          .exclude(deleted=True) \
          .annotate(num_calculations=Count('user__calculations'))\
          .order_by("-user__date_joined")
  </code></pre>
  
  <p>With this query I get all members and total calculations that they have done.</p>
  
  <p>How can I get total calculations per month(last 12 months)?</p>
  
  <p>Calculation model is as follows:</p>
  
  <pre><code>class Calculations(models.Model):
      user = models.ForeignKey(to=User)
      make = models.CharField(max_length=127)
      model = models.CharField(max_length=127)        
      mileage = models.IntegerField()        
      price_date = models.DateTimeField(auto_now_add=True)
      sales_price_currency = models.CharField(max_length=10, null=True)
  </code></pre>
  
  <p>And member model is as follows:</p>
  
  <pre><code>class Member(models.Model):
      user = models.ForeignKey(to=User)
      number = models.CharField(max_length=10)        
      company_name = models.CharField(max_length=100)
      address = models.CharField(max_length=255)
      mobile = models.CharField(max_length=50)
      active = models.BooleanField()
      deleted = models.NullBooleanField(null=True)
  </code></pre>