﻿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
21537	Add a bit more flexibility to  the multi-table model inheritance	ivanbright@…	nobody	"Hi. I'm sorry if it's not a proper place for such an issue, but i've not found the another way to contact to you.

I suppose, it would be useful if Django would allow to create an instance of derived model based on the existing instance of the parent model.

Let's consider two simple models (Django v1.5.5 assumed), one inherited from another:

{{{

from django.db import models

class StreetAddress(models.Model):
    street_name = models.CharField(max_length=64)
    building_number = models.PositiveSmallIntegerField()

    def __str__(self):
        return ""%s %d"" % (self.street_name, self.building_number)

class Cafe(StreetAddress):
    name = models.CharField(max_length=64)
}}}


StreetAddress intentionally created as non-abstract, because i suppose its instances being created independently from the cafe instances or another possible descendants. Let's try to create some cafe located by some address:


{{{
Python 2.7.4 (default, Apr 19 2013, 18:28:01) 
[GCC 4.7.3] on linux2
Type ""help"", ""copyright"", ""credits"" or ""license"" for more information.
(InteractiveConsole)
>>> from heir_demo.models import StreetAddress, Cafe
>>> addr = StreetAddress.objects.create(street_name='Piccadilly', building_number=5)
>>> addr
<StreetAddress: Piccadilly 5>

>>> mollys = Cafe.objects.create(streetaddress_ptr=addr, name='Mollys')
Traceback (most recent call last):
  File ""<console>"", line 1, in <module>
  ...  stacktrace goes here ...
Warning: Column 'building_number' cannot be null
}}}



I posted it on [http://stackoverflow.com/questions/20287111/the-want-of-consistency-in-django-models-inheritance/]. Thus, if i just misunderstand something, please, post an explanation there.

Thank you.

"	New feature	closed	Database layer (models, ORM)	1.5	Normal	duplicate	model inheritance multi-table		Unreviewed	1	0	0	0	0	0
