#29574: Unable to create model instance after changing an abstract model to non-
abstract due to "foreign key mismatch" error
----------------------------+-------------------------------------
     Reporter:  josephbiko  |                    Owner:  Calvin Vu
         Type:  Bug         |                   Status:  assigned
    Component:  Migrations  |                  Version:  2.1
     Severity:  Normal      |               Resolution:
     Keywords:              |             Triage Stage:  Accepted
    Has patch:  0           |      Needs documentation:  0
  Needs tests:  0           |  Patch needs improvement:  0
Easy pickings:  0           |                    UI/UX:  0
----------------------------+-------------------------------------
Comment (by Calvin Vu):

 Replying to [comment:15 Calvin Vu]:
 > It seems like Bhuvnesh correctly identified the cause. A potential
 solution would be to first set `C.fk` to `A.id` (which is going to be the
 `id` of model 'AB', i.e., the separate tables A and B, which are connected
 one-to-one with `B.a_ptr_id` when model A is made concrete), then change
 model B to inherit from model A (to form model 'AB'), and then update any
 existing data. Alternatively, we could also set `C.fk` to `B.a_ptr_id` as
 it is also a primary key.
 Nevermind, this solution probably won't work because we need B to inherit
 from A to determine exactly which A instance to set C.fk to but when B
 inherits from A we lose B.id so there would be no way to link C and 'AB'
-- 
Ticket URL: <https://code.djangoproject.com/ticket/29574#comment:16>
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070192a414b4d7-258760c7-ad90-44a0-a137-a20b310cc8ed-000000%40eu-central-1.amazonses.com.

Reply via email to