{{{
class ModelA(models.Model):
field_wrong = models.CharField('field1', max_length=50,
primary_key=True) # I'm a Primary key.
}}}
{{{
class ModelB(models.Model):
field_fk = models.ForeignKey(ModelA, blank=True, null=True,
on_delete=models.CASCADE)
}}}
... migrations applyed ...
the `ModelA.field_wrong` field has been renamed ... and Django recognizes
the "renaming"
{{{
# Primary key renamed
class ModelA(models.Model):
field_fixed = models.CharField('field1', max_length=50,
primary_key=True) # I'm a Primary key.
}}}
Attempts to [[span(style=color: #FF0000, to_field)]] parameter.
The **to_field** points to the **old_name** (**field_typo**) and not to
the new one ("**field_fixed**")
{{{
class Migration(migrations.Migration):
dependencies = [
('app1', '0001_initial'),
]
operations = [
migrations.RenameField(
model_name='modela',
old_name='field_wrong',
new_name='field_fixed',
),
migrations.AlterField(
model_name='modelb',
name='modela',
field=models.ForeignKey(blank=True, null=True,
on_delete=django.db.models.deletion.CASCADE, to='app1.ModelB',
to_field='field_wrong'),
),
]
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30868>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* severity: Release blocker => Normal
* cc: Simon Charette (added)
* version: 2.2 => master
* easy: 1 => 0
* stage: Unreviewed => Accepted
Comment:
Thanks for this ticket. It looks like a regression in
dcdd219ee1e062dc6189f382e0298e0adf5d5ddf, because an `AlterField`
operation wasn't generated in such cases before this change (and I don't
think we need it).
--
Ticket URL: <https://code.djangoproject.com/ticket/30868#comment:1>
* owner: nobody => Simon Charette
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/30868#comment:2>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/30868#comment:3>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"2839659b42ef80038152768b6cedae1016c59d90" 2839659b]:
{{{
#!CommitTicketReference repository=""
revision="2839659b42ef80038152768b6cedae1016c59d90"
Fixed #30868 -- Prevented unnecessary AlterField when renaming a
referenced pk.
Regression introduced by dcdd219ee1, refs #25817.
Thanks Carlos E. C. Leite for the report and Mariusz for the bisect.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30868#comment:4>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"bab3ad54ff30848a16f08d72e70d8edbab019a63" bab3ad5]:
{{{
#!CommitTicketReference repository=""
revision="bab3ad54ff30848a16f08d72e70d8edbab019a63"
[3.0.x] Fixed #30868 -- Prevented unnecessary AlterField when renaming a
referenced pk.
Regression introduced by dcdd219ee1, refs #25817.
Thanks Carlos E. C. Leite for the report and Mariusz for the bisect.
Backport of 2839659b42ef80038152768b6cedae1016c59d90 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30868#comment:5>
Comment (by Harro):
Should this be backported to the 2.x branch too?
Seems the same issue is there.
--
Ticket URL: <https://code.djangoproject.com/ticket/30868#comment:6>
Comment (by felixxm):
Unfortunately this patch doesn't qualify for a backport.
--
Ticket URL: <https://code.djangoproject.com/ticket/30868#comment:7>