0

I basically have the same question Move models between Django (1.8) apps with required ForeignKey references. The response from @halfnibble seems valid but in my case there is a ForeignKey pointing from new_app to old_app. I wil translate my names to names on @halfnibble example for simplicity, Tires will have a ForeignKey to Car.

The migrations runs fine. Few migrations later I rename old_app.Car to old_app.NewCar (I don't know if this affects). But some migrations later when I try to delete new_app.Tires and in next migration old_app.NewCar I get the error:

>python manage.py migrate
  ....
ValueError: Unhandled pending operations for models:
  old_app.newcar (referred to by fields: new_app.Tires.car)

If I run my apps tests they run correctly, I have also inspected generated MySQL queries and seems correct.

Community
  • 1
  • 1
Chemary
  • 1,304
  • 12
  • 18

1 Answers1

1

I found the error, I left this information in case anybody has the same problem.

The problem was really induced by the rename of old_app.Car to old_app.NewCar.

makemigrations detected the change and created two migrations one in old_app with the rename and other on new_app updating the ForeingKey. The problem was that you have to manually add in new_app dependencies the old_app migration where the model was renamed.

Chemary
  • 1,304
  • 12
  • 18