views:

162

answers:

3
+2  A: 

I think you should try:

class Door(models.Model):
    bar = models.CharField(max_length=123)

class House(models.Model):
    foo = models.CharField(max_length=123)
    door = models.ForeignKey(Door)

class Caravan(models.Model):
    foo = models.CharField(max_length=123)
    door = models.ForeignKey(Door)
Aurelio Martin
There may be many doors in a house or in a caravan...
toaster
So use a ManyToManyField.
Daniel Roseman
+4  A: 
class Door(models.Model):
    bar = models.CharField(max_length=123)

class Caravan(models.Model):
    foo = models.CharField(max_length=123)
    doors = models.ManyToManyField(Door)

class House(models.Model):
    foo = models.CharField(max_length=123)
    doors = models.ManyToManyField(Door)
nabucosound
+1  A: 

Can you clarify what you're really looking for with an example query? It's not clear to me. This is what I think you're looking for:

class Door(models.Model):
  bar = models.CharField(max_length=123)

class House(Door):
  foo = models.CharField(max_length=123)

class Caravan(Door):
  foo = models.CharField(max_length=123)

Then you can do things like Caravan.objects.values('foo','bar')

Adam Nelson