title: Count and Max after values() method on Django query
body: <p>I have this Django model:</p>
  
  <pre><code>class Action(models.Model):
      id = models.AutoField(primary_key=True)
      game = models.ForeignKey(Game)
      step = models.ForeignKey(Step)
      from_player = models.ForeignKey(Player)
      to_player = models.ForeignKey(Player)
      type = models.ForeignKey(ActionType)
      timestamp = models.DateTimeField(default=timezone.now)
  </code></pre>
  
  <p>I want to do the following:</p>
  
  <ol>
  <li>Filter on game, step and type</li>
  <li>Find the player/players how has/have obtained the highest number of actions</li>
  </ol>
  
  <p>to do so I tried:</p>
  
  <pre><code>v = Action.objects.filter(game=1, step=2)
  v = v.filter(type=3)
  v = v.values('to_player').order_by().annotate(count=Count('to_player'))
  v = v.annotate(max=Max('count')).filter(count=F('max')) #try to select the max
  </code></pre>
  
  <p>but last line gives me (because line 3 returns a list of dictionaries):</p>
  
  <pre><code>Cannot compute Max('count'): 'count' is an aggregate
  </code></pre>
  
  <p>I know that probably something similar has already been answered but Django values() and aggregate() are a bit tricky to me. Which is the right way to do this?</p>