Skip to content
Advertisement

Django Migrations Circular Dependencies

so my django project was working completely fine and everything worked.

I wanted to rename an app something else so I did and updated all the associated files in including the app.py config file.

I also cleared the database and removed all migration files from each app.

Ever since then I have never been able to finish makemigrations onto my apps.

I even recreated the app I renamed, by doing django-admin startapp “appname” and then copied the contents of models.py admin.py, etc over to see if I somehow cause an internal issue but I just can’t figure out what’s going on?.

I did manage to get all the makemigrations to success for all apps including the one I remade when I removed this (below) from another apps admin.py file

JavaScript

but in the end the python manage.py migrate, still Failed. If someone would help it would be highly appreciated.

Here is the error-code:

JavaScript

Dependencies in accounts/migrations/0001_initial.py

JavaScript

Dependencies in accounts/migraitons/0002_auto_20210809_1910.py

JavaScript

Dependencies in signals/migrations/0001_initial.py

JavaScript

Advertisement

Answer

Dependencies in accounts/migrations/0001_initial.py

JavaScript

Dependencies in accounts/migraitons/0002_auto_20210809_1910.py

JavaScript

Dependencies in signals/migrations/0001_initial.py

JavaScript

This tells us the following:

  1. accounts.0001.initial depends on signals.0001_initial (specified by '__first__'.
  2. accounts.0002_auto_20210809_1910 depends on accounts.0001.initial
  3. signals.0001_initial.py depends on accounts.0002_auto_20210809_1910

The circularity should be clear.

You can either edit these dependencies manually or delete all migrations and generate them again with ./manage.py makemigrations This should solve the problem unless there are underlying issues with the model dependencies themselves.

WARNING

Be very careful when editing or deleting migrations. If your project is deployed to a live server, editing migrations that have already applied will at best do nothing and at worst completely wreck your production database. The proceeding suggestion should only be used if you are working on a project that has not yet been deployed.

Advertisement