﻿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
30531	Exception when creating an inherited model object with existing base	Victor Porton	nobody	"The following intuitively right causes an exception:

{{{
class Base(models.Model):
    v = models.IntegerField()

class Derived(Base):
    base = models.OneToOneField(Base, on_delete=models.CASCADE, primary_key=True)

class BugTestCase(TestCase):
    def setUp(self):
        self.base = Base.objects.create(v=0)

    def test_bug(self):
        Derived.objects.create(base=self.base)
}}}

Here it is:

{{{
django.db.utils.IntegrityError: NOT NULL constraint failed: mytest_base.v
}}}

It should work in the expected way not to raise an exception.

In the project I am developing now, I am going to write a workaround with a raw SQL query :-(

I will attach full test source."	Bug	closed	Database layer (models, ORM)	2.2	Normal	invalid			Unreviewed	0	0	0	0	0	0
