0

I'm working with a few people on an app. I'm doing front end.

Recently, I've messed up migrations. After trying to fix them for a few hours, I've dropped all tables, and cloned the repo again.

Since there are no migrations files, I run manage.py makemigrations (for some reason it does not detect all apps, just one of them, and I have to call makemigrations manually for each of them).

Then, I run manage.py migrate. I get the following error:

Related model 'User.user' cannot be resolved

Since User table has OneToOneField relation to User table. Also, other tables depend on each other as well.

My take on this problem would be commening out all the fields that cause the problem, making migrations, uncommenting them, and making migrations again.

How should I fix it?

aurelia
  • 493
  • 8
  • 12

1 Answers1

0

Ok, I solved this particular problem:

In User app there was another model, which referred to User. Automatically created migration file had this model before User model, so the script failed, since it could not refer to a model that is yet not created.

I solved this by editing the migration file, swapping the order of creating models - so the second model can refer to the first one.

aurelia
  • 493
  • 8
  • 12