title: Django: select_related with multi table inheritance
body: <p>I have the following model structure:</p>
  
  <pre><code>class A(models.Model):
      prop_a = models.CharField(max_length=255)
  
  class B(A):
      prop_b = models.CharField(max_length=255)
  
  class C(A):
      prop_c = models.CharField(max_length=255)
  
  class D(models.Model):
      fk = models.ForeignKey('A')
  </code></pre>
  
  <p>So essentially, I have a model (<code>D</code>) which has a foreign key to an 'abstract' model (<code>A</code>) which is subclassed by <code>B</code> and <code>C</code>.</p>
  
  <p>Now, when I run <code>D.objects.all().select_related()</code>, only the properties of <code>A</code>are queried. I assume this is because at query time, Django does not know which child class the <code>fk</code> is an instance of (and neither do I in my current structure).</p>
  
  <p>Is there any way to query the properties of the child class without changing the model structure? </p>
  
  <p>I also tried prefetch_related and tried using an InheritanceManager from <a href="https://github.com/jazzband/django-model-utils" rel="nofollow noreferrer">django-model-utils</a>, both to no avail.</p>
  
  <p><strong>Edit:</strong> To clarify, I am looking for a way to iterate over objects of <code>D</code>, accessing the concrete values of <code>fk</code> (which are either <code>B</code> or <code>C</code> objects) while only hitting the database once.</p>
  
  <p>Running <code>D.objects.all().select_related()</code> produces the query</p>
  
  <p><code>'SELECT "mapping_d"."id", "mapping_d"."fk_id", "mapping_a"."id", "mapping_a"."prop_a" FROM "mapping_d" INNER JOIN "mapping_a" ON ("mapping_d"."fk_id" = "mapping_a"."id")'</code></p>
  
  <p>Let's say one of those is an object <code>d</code> of type <code>D</code> whose property <code>fk</code> is of type <code>C</code>.</p>
  
  <p>Now, when I access the value <code>d.fk.c</code>, Django runs an additional query to get the properties of C:</p>
  
  <p><code>'SELECT "mapping_a"."id", "mapping_a"."prop_a", "mapping_c"."a_ptr_id", "mapping_c"."prop_c" FROM "mapping_c" INNER JOIN "mapping_a" ON ("mapping_c"."a_ptr_id" = "mapping_a"."id") WHERE "mapping_c"."a_ptr_id" = 3'</code></p>
  
  <p>I want to avoid this additional query per object of D. Using an InheritanceManager in the proposed way does not seem to do that.</p>