I understand that -- my question is why the AlterField operation in this case didn't add a migration dependency.
On Wednesday, May 27, 2020 at 6:44:16 PM UTC-10, Durai pandian wrote:
-- On Wednesday, May 27, 2020 at 6:44:16 PM UTC-10, Durai pandian wrote:
When you make any changes to the field, AlterField will be added rather than AddField.On Thu, May 28, 2020 at 7:32 AM Erin Masatsugu <erin.m...@gmail.com> wrote: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/ so I don't believe this is expected behavior, but can someone confirm?migration$20dependency%7Csort: date/django-users/-h9LZxFomLU/ ry_yeWGfDQAJ 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 django...@googlegroups.com .
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/48ab3732- .f667-472f-a678-ca9f082315da% 40googlegroups.com
--
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 django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/70b206b3-fec7-4d0d-ae29-5ae07eef53d5%40googlegroups.com.
No comments:
Post a Comment