#24282: Cannot Modify Foreign Keys Within Data Migrations
-------------------------------------+-------------------------------------
     Reporter:  Jeff Singer          |                    Owner:  Markus
                                     |  Holtermann
         Type:  Bug                  |                   Status:  new
    Component:  Migrations           |                  Version:  1.8alpha1
     Severity:  Release blocker      |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Ubica):

 * status:  closed => new
 * resolution:  fixed =>


Comment:

 I am getting this same issue in Django==2.2.10 as well as 2.2.17

 When using models obtained from {{{apps.get_model}}} they are returned as
 <class '__fake__.ModelName'> and if I try to assign it to a ForeignKey
 field that causes a ValueError Exception:
 {{{
 ValueError: Cannot assign "<ModelName: ModelName object (10232)>":
 "ModelName.field_name" must be a "ModelName" instance.
 }}}

 This can be avoided by using PKs instead, but I am not sure if it's
 supposed to work with objects as well.
 {{{
 instance.foreign_key_field_id = instance.pk
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/24282#comment:15>
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/069.c243ded296c1724e7f9086fe9abfaca1%40djangoproject.com.

Reply via email to