title: Django ORM query with multiple join fields
body: <p>How could I make this mysql query into django ORM?</p>
  
  <pre><code>SELECT search_products.model, search_products.year, search_products.size, search_avg_price.estimated_price
  FROM search_products
  left JOIN search_avg_price
  ON search_products.model=search_avg_price.model and search_products.size=search_avg_price.size and search_products.year=search_avg_price.year
  </code></pre>
  
  <p>I have already tried</p>
  
  <pre><code>latest_products = Products.objects.all().prefetch_related("avg_price")
  </code></pre>
  
  <p>but this is translated by django as</p>
  
  <pre><code>SELECT `search_products`.`id`, `search_products`.`size`, `search_products`.`year`, , `search_products`.`model`, `search_products`.`avg_price_id`
  FROM `search_products`
  </code></pre>
  
  <p>and</p>
  
  <pre><code>latest_products = Products.objects.all().select_related("avg_price")
  </code></pre>
  
  <p>This is translated by django as:</p>
  
  <pre><code>SELECT `search_products`.`id`, `search_products`.`size`, `search_products`.`year`, , `search_products`.`model`, `search_products`.`avg_price_id`, `search_avg_price`.`id`, `search_avg_price`.`model`, `search_avg_price`.`size`, `search_avg_price`.`year`, `search_avg_price`.`estimated_price` 
  FROM `search_products` 
  INNER JOIN `search_avg_price` ON ( `search_products`.`avg_price_id` = `search_avg_price`.`id` )
  </code></pre>
  
  <p>if I run the above SQL in the database I get the proper result... </p>
  
  <p>Edit: Models and views</p>
  
  <pre><code>class Avg_price(models.Model):
   model = models.CharField(max_length=50, blank=True)
   size= models.IntegerField(blank=True, null=True)
   year= models.IntegerField(blank=True, null=True)
   estimated_price= models.IntegerField(blank=True, null=True)
  
  class Products(models.Model):
   product_id =models.IntegerField(blank=True, null=True)
   link_id = models.CharField(max_length=200, blank=True)
   location = models.CharField(max_length=200, blank=True)
   model = models.CharField(max_length=50, blank=True)
   size= models.IntegerField(blank=True, null=True)
   price= models.IntegerField(blank=True, null=True)
   year= models.IntegerField(blank=True, null=True)
   type=models.ForeignKey(Type)
   avg_price = models.ForeignKey(Avg_price)
  
   def __unicode__(self):  # Python 3: def __str__(self):
     return self.location
  </code></pre>
  
  <p>Template</p>
  
  <pre><code>{% if latest_products %}
    {% for product in latest_products %}
    &lt;ul&gt;
      &lt;li id="col_one"&gt;
        &lt;h5&gt;{{product.avg_price.estimated_price}}&lt;/h5&gt;
        &lt;h5&gt;{{product.model}}&lt;/h5&gt;
  </code></pre>