#30531: Exception when creating an inherited model object with existing base
               Reporter:  Victor     |          Owner:  nobody
  Porton                             |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  2.2
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
 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,

 class BugTestCase(TestCase):
     def setUp(self):
         self.base = Base.objects.create(v=0)

     def test_bug(self):

 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.

Ticket URL: <https://code.djangoproject.com/ticket/30531>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to