title: in Django ORM, how to get a count in a reverse set query
body: <p>I have these three models:</p>
  
  <pre><code>class Member (models.Model):
      FederationID = models.FloatField(unique=True)
      User = models.ForeignKey(User, on_delete=models.CASCADE)
      height = models.IntegerField(blank=True, null=True)
      eye = models.CharField(blank=True, null=True, max_length=10)
      hair = models.CharField(blank=True, null=True, max_length=10)
      birthdate = models.DateField()
      bio = models.TextField()
      Address = models.ForeignKey(Address, on_delete=models.CASCADE, null=True, blank=True)
      Phone = models.ForeignKey(Phone, on_delete=models.CASCADE, null=True, blank=True)
      Photos = models.ManyToManyField(Photos)
      Rank = models.ManyToManyField('Rank', through='Promotion')
      Unit = models.ManyToManyField('Unit', through='Assignment')
  
  class Genre(models.Model):
      ShortName = models.CharField(max_length=50)
      LongName = models.CharField(max_length=500)
  
      def __str__(self):
          return self.LongName + ' (' + self.ShortName + ')'
  
  
  class Career(models.Model):
      ShortName = models.CharField(max_length=50)
      LongName = models.CharField(max_length=500)
  
      def __str__(self):
          return self.LongName + ' (' + self.ShortName + ')'
  
  
  class Rank(models.Model):
      RANK_TYPE_CHOICES = (
          ('O', 'Officer'),
          ('E', 'Enlisted'),
          ('V', 'Civilian'),
          ('C', 'Cadet'),
      )
      ShortName = models.CharField(max_length=50)
      LongName = models.CharField(max_length=500)
      Type = models.CharField(max_length=1, choices=RANK_TYPE_CHOICES, default='O')
      Genre = models.ForeignKey(Genre, on_delete=models.DO_NOTHING)
      Career = models.ForeignKey(Career, on_delete=models.DO_NOTHING)
      image = models.ForeignKey(Photos, on_delete=models.DO_NOTHING)
  
      def __str__(self):
          return self.LongName + ' (' + self.Career.LongName + ') from ' + self.Genre.LongName
  
  
  class Promotion(models.Model):
      Rank = models.ForeignKey(Rank, on_delete=models.DO_NOTHING)
      Member = models.ForeignKey(Member, on_delete=models.CASCADE)
      PromotionDate = models.DateField(default=now)
  
      def __str__(self):
          return self.Member.User.first_name + ' ' + self.Member.User.last_name + ' promoted to ' + self.Rank.LongName + ' on ' + str(self.PromotionDate)
  </code></pre>
  
  <p>I created a many-to-many relationship between Rank and Member via Promotion.<br>
  In the model Rank, I have the <code>Type</code> field.</p>
  
  <p>I need a count and group by the type field for each member on their latest Promotion.</p>
  
  <p>like this: <code>{'officer':4, 'enlisted':2, 'Civilian':12}</code></p>
  
  <p>I added this to get the rank for each member:</p>
  
  <pre><code>self.promotion_set.latest('PromotionDate').Rank
  </code></pre>
  
  <p>but I need this for the group.</p>
  
  <p>I appreciate any wisdom in here. Thanks</p>