title: A less expensive way to find the position of a model in a queryset?
body: <p>I have two models:</p>
  
  <pre><code>class Person(models.Model):
      name = models.CharField()
      email = models.EmailField()
  
  class Vote(models.Model):
      person = models.ForeignKey('Person', related_name='votes')
      email = models.EmailField()
  </code></pre>
  
  <p>I can get the position of a person using this method on the person model:</p>
  
  <pre><code>@property
  def position(self):
      person_list = Person.objects.annotate(Count('votes')).order_by(
          '-votes__count', 'name')
      for i, x in enumerate(person_list, start=1):
          if x == self:
              return i
  </code></pre>
  
  <p>The problem is the person_list queryset is evaluated every time the position method is called which in my opinion is firing off unnecessary queries to the database as this query only needs to be run once during the request/response cycle. Ideally I want to take advantage of the queryset cache. Does anyone have any idea how I would do that?</p>
  
  <p>Thanks.</p>
  
  <p>EDIT: I'm calling the position method from a template so I don't think I can pass in the queryset as an arg.</p>