4👍
The reason for this is that migrations.CreateModel
migration for Body
is present in migration file before CreateModel
for Car
, more specifically, that it has
('car', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, parent_link=True, to='polls.Car', verbose_name='Машина')),
line in Body
CreateModel before Car
model was created.
This is probably because car
field on Body
has parent_link=True
, which indicates that link should be made to parent model and thus this field will not be present on current (child) model and it is safe to include this field in migration where it is.
But in your case this is not child model, it is not inherited from any parent model, so using parent_link=True
is not needed.
Best option is to remove parent_link=True
, remove previously created migration file and re-create migrations.
Another option is to simply edit migration file and move CreateModel for Body
after CreateModel for Car
, but this is not recommended.