Description
Having these two models
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 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'),
),
]
d232fd76a858 (django/django 3.1), dependencies installed and tests runnable from the first minute. You are graded by hidden tests taken from the fix that was actually merged upstream.