﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
7623	Multi-table inheritance: Add the ability create child instance from existing parent	brooks.travis@…		"As it exists now, multi-table inheritance does not allow for the creation of a child model instance that inherits from an existing parent model instance. For example:

Parent Class-


{{{
class Place(models.Model):
    name = models.CharField(max_length=50)
    address = models.TextField(max_length=150)
}}}


Child Classes-


{{{
class Restaurant(Place):
    place = models.OneToOneField(Place, parent_link=True)
    cuisine = models.CharField(max_length=75)
    rating = models.IntegerField()

class Bar(Place):
    parent = models.OneToOneField(Place, parent_link=True)
    happy_hour = models.BooleanField()
    beers_on_tap = models.ManyToManyField(""Beers"", null=True, blank=True)
}}}


Sample Use-case-

When the system is first deployed, a restaurant instance is created. Later, the restaurant adds a bar to increase revenue, and we now want to create a Bar model instance for the parent Place for the restaurant. I would propose the following interface for doing so:


{{{
parentPlace = Restaurant.objects.get(name__iexact=""Bob's Place"").parent
barInstance = Bar(parent=parentPlace, happy_hour=True)
}}}


However, if you attempt to create an instance in this manner now, you receive a DatabaseIntegrityError, saying that a Place object with that id already exists."	New feature	new	Database layer (models, ORM)	dev	Normal		model-inheritance, multi-table-inheritance	brooks.travis@… sirexas@… anssi.kaariainen@… mike@… reza@… cmawebsite@… Aron Podrigal kamandol Carlos Palol Matias Rodal Bel-Shazzar InvalidInterrupt JM Barbier Charlie Denton	Accepted	1	0	1	1	0	0
