title: Django Model Inheritance And Foreign Keys
body: <p>Basically, I have a model where I've created a superclass that many other classes share, and then each of those classes has some unique features that differ from each other. Let's say class A is the superclass, and class B, C, and D are children of that class.</p>
  
  <p>Both class B and class C can have multiples of class D, however I've seen that it's best to put the foreign key relationship in class D, which then refers to its parent class. Now in other languages, I could simply say it has a ForeignKey relationship to class A, and then the language recognizes the classes' true type. However, I don't think that's how it works with Python.</p>
  
  <p>What's the best recommended way of pursuing this issue?</p>
  
  <p>EDIT: Here is roughly what I mean...</p>
  
  <pre><code>class A(models.Model):
      field = models.TextField()
  
  class B(A):
      other = &lt;class specific functionality&gt;
  
  class C(A):
      other2 = &lt;different functionality&gt;
  
  class D(A):
      #I would like class D to have a foreign key to either B or C, but not both.
  </code></pre>
  
  <p>Essentially, class B and class C both have multiple class D's. But a particular class D only belongs to one of them.</p>