title: Django model subclassing: Get the subclass by querying the superclass
body: <p>The following code is given:</p>
  
  <pre><code>class BaseMedium(models.Model):
      title = models.CharField(max_length=40)
      slug = models.SlugField()
  
  class A(BaseMedium):
      url = models.URLField()
  
  class B(BaseMedium):
      email = models.EmailField()
  </code></pre>
  
  <p>I now want to query every BaseMedium.</p>
  
  <pre><code>b = BaseMedium.objects.all()
  </code></pre>
  
  <p>How do I print every information including the subclass fields without knowing what the subclass type is?</p>
  
  <p><code>b[0].a</code> would print the information if <code>b[0]</code> is actually related to an <code>A</code> instance but if it's related to <code>B</code> it would print an <code>DoesNotExist</code> Exception. </p>
  
  <p>This makes sense but I'd like to have a common variable or method that returns the related object.</p>
  
  <p>Maybe my Database layout isn't really great to query that way if so I'd be glad if you'd recommend a better layout.</p>
  
  <p>I thought about using a <code>GenericForeignKey</code></p>
  
  <pre><code>class Generic(models.Model):
      basemedium = models.ForeignKey('BaseMedium')
      content_type = models.ForeignKey(ContentType)
      object_id = models.PositiveIntegerField()
      object = generic.GenericForeignKey('content_type', 'object_id')
  </code></pre>
  
  <p>but this solution seems to be to complicated and I think you guys have better solutions.</p>