Sunday 12 January 2020

Reordering Initial Migration operations

Every time I try to migrate my initial migration, right after makemigrations, I get errors like :

django.db.migrations.exceptions.InvalidBasesError: Cannot resolve bases for [<ModelState: 'Project.Class'>]
This can happen if you are inheriting models from an app with migrations (e.g. contrib.auth)

The reason I think this happens is because the order of model operations in the 0001_initial.py migration is incorrect. Operations with classes which inherit from others are added before their parents'. After I reorder the operations, it works: Process finished with exit code 0. Cool! But how do I make makemigrations work without doing this every time?

Thanks!

ps. I tried reordering the import order of my models in the model's __init__.py but it didn't work.



from Reordering Initial Migration operations

No comments:

Post a Comment