#27903: RenameModel does not not change ForeignKey with related_name='+'
-------------------------------------+-------------------------------------
     Reporter:  Alexander Schrijver  |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Migrations           |                  Version:  1.10
     Severity:  Normal               |               Resolution:  fixed
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Alexander Schrijver):

 As a workaround you can do is: before the RenameModel with a AlterField
 set the ForeignKey's related_name to some temporary value, and then set it
 back to '+' when you've done the RenameModel. e.g.:

 {{{
 migrations.AlterField(
     model_name='SomeModel',
     name='some_field',
     field=models.ForeignKey(... related_name='xxx', to='app.OtherModel'),
 ),
 migrations.RenameModel('OtherModel', 'OtherModel2'),
 migrations.AlterField(
     model_name='SomeModel',
     name='some_field',
     field=models.ForeignKey(... related_name='+', to='app.OtherModel2'),
 ),
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27903#comment:4>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.5db70158940a4ae8c3f17a9250de406e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to