Multi-table inheritance - knowing the child object from the parent

2010-05-17 Thread Lee Hinde
Given the following: class Place(models.Model): name = models.CharField(max_length=50) address = models.CharField(max_length=80) zip_code = models.CharField(max_length=15) class Restaurant(Place): serves_hot_dogs = models.BooleanField() serves_pizza = models.BooleanField() c

Re: Multi-table inheritance - knowing the child object from the parent

2010-05-18 Thread Jani Tiainen
> Given the following: > > class Place(models.Model): > name = models.CharField(max_length=50) > address = models.CharField(max_length=80) > zip_code = models.CharField(max_length=15) > > > class Restaurant(Place): > serves_hot_dogs = models.BooleanField() > serves_pizza = mo

Re: Multi-table inheritance - knowing the child object from the parent

2010-05-18 Thread Lee Hinde
On Tue, May 18, 2010 at 4:27 AM, Jani Tiainen wrote: > > Given the following: > > > > class Place(models.Model): > > name = models.CharField(max_length=50) > > address = models.CharField(max_length=80) > > zip_code = models.CharField(max_length=15) > > > > > > class Restaurant(Place):

Re: Multi-table inheritance - knowing the child object from the parent

2010-05-18 Thread Jori
http://docs.djangoproject.com/en/1.2/topics/db/models/#id7 You can access sub-classes with place.restaurant and place.gardenstore if the model has them. I did something similar the other day but added an extra field to parent class to indicate which type of a child model it had (1 for Restaurant