If I have this a model in app A:
class AppAModel(models.Model):
    name = models.CharField(max_length=50, default="")

and this model in app B:
class AppBModel(models.Model):
    name = models.CharField(max_length=50, default="")

and a I add a foreign key to AppAModel in app C:
class AppCModel(models.Model):
    my_field = models.ForeignKey(AppAModel, on_delete=models.CASCADE)

the generated migration file correctly adds a dependency from app C to app 
A:
class Migration(migrations.Migration):

    dependencies = [
        ('app_a', 'XXXX_app_a_migration'),
        ('app_c', 'XXXX_app_c_migration'),
    ]

    operations = [
        migrations.CreateModel(
            name='AppCModel',
            fields=[
                ('id', models.AutoField(auto_created=True, 
primary_key=True, serialize=False, verbose_name='ID')),
                ('my_field', 
models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, 
to='ncm.AppAModel')),
            ],
        ),
    ]

However, if I then update my_field to instead have a foreign key to 
AppBModel, django doesn't add a migration dependency from app C to app B:
class Migration(migrations.Migration):

    dependencies = [
        ('app_c', 'XXXX_app_c_migration'),
    ]

    operations = [
        migrations.AlterField(
            model_name='appcmodel',
            name='my_field',
            
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, 
to='metals.AppBModel'),
        ),
    ]

I saw the response here 
https://groups.google.com/forum/#!searchin/django-users/migration$20dependency%7Csort:date/django-users/-h9LZxFomLU/ry_yeWGfDQAJ
 
so I don't believe this is expected behavior, but can someone confirm?

Thank you!
Erin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" 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-users/48ab3732-f667-472f-a678-ca9f082315da%40googlegroups.com.

Reply via email to