title: How to do this join query in Django
body: <p>In Django, I have two models:</p>
  
  <pre><code>class Product(models.Model):
      name = models.CharField(max_length = 50)
      categories = models.ManyToManyField(Category)
  
  class ProductRank(models.Model):
      product = models.ForeignKey(Product)
      rank = models.IntegerField(default = 0)
  </code></pre>
  
  <p>I put the rank into a separate table because every view of a page will cause the rank to change and I was worried that all these writes would make my other (mostly read) queries slow down.</p>
  
  <p>I gather a list of <code>Products</code> from a simple query:</p>
  
  <pre><code>cat = Category.objects.get(pk = 1)
  products = Product.objects.filter(categories = cat)
  </code></pre>
  
  <p>I would now like to get all the ranks for these products. I would prefer to do it all in one go (using a SQL join) and was wondering how to express that using Django's query mechanism.</p>
  
  <p>What is the right way to do this in Django?</p>