[Django]-Django: dependencies reference nonexistent parent node

68๐Ÿ‘

โœ…

Solution โ€“ 1

Remove pyc files from your migrations folder.

Solution โ€“ 2

Need to remove that reference from testBolt.0001_initial by editing migration file.

Solution โ€“ 3

  1. Remove the new changes from the models and run python manage.py migrate --fake

  2. Now again modify your models with new changes

  3. Run python manage.py makemigrations

  4. And then again run python manage.py migrate

๐Ÿ‘คNIKHIL RANE

15๐Ÿ‘

In my case, I had the .py extension in the dependency module name, like this:

dependencies = [
    ('dashboard', '0003_auto_20181024_0603.py'),
    ('auth', '__latest__'),
    ('contenttypes', '__latest__'),
]

I removed the .py, changing the line to this

    ('dashboard', '0003_auto_20181024_0603'),

and that fixed it.

๐Ÿ‘คChristian Long

10๐Ÿ‘

I had the same problem. In my case, because I played with migrations manually, I forgot to create __init__.py inside of migrations folder.

๐Ÿ‘คTitanFighter

9๐Ÿ‘

This works for me
In your app migrations folder

  1. Delete all the files pyc in your app folder (except the __init__)
  2. Delete all the files in the migrations (except the __init__ )

  3. python manage.py makemigrations

  4. python manage.py migrate
  5. runserver

5๐Ÿ‘

I had a similar case, running django in windows in a virtual env. In my case the missing dependency was 0001_initial โ€“ which was definitely there in the migration folder.

The โ€˜solutionโ€™ was to remove the pyc files and do another migrate attempt.

๐Ÿ‘คjbos1234

5๐Ÿ‘

Hereโ€™s how it worked for me:

  1. Deleted all the __pycache__ folders inside every app.
  2. Deleted all the files inside the migration folder except for __init.py__ inside each app folder.
  3. python manage.py makemigrations
  4. python manage.py migrate
  5. python manage.py runserver
๐Ÿ‘คSachin

4๐Ÿ‘

I tried NIKHILโ€™s solutions with no luck. What did work for me was:

  • Removing my virtual environment
  • Deleting the migration __pycache__ folders
  • Deleting old migrations
  • Recreating my virtual environment
  • Running migrations
๐Ÿ‘คProgrammingjoe

4๐Ÿ‘

KeyError: u"Migration testBolt.0001_initial dependencies reference nonexistent parent node (u'delivery_boy', u'0004_auto_20150221_2011')"

Remove

testBolt.0001_initial

then run migrate again

๐Ÿ‘คHoangYell

3๐Ÿ‘

Make sure that you have activated your virtual environment.

๐Ÿ‘คDawn T Cherian

3๐Ÿ‘

This worked for me:

  • Delete environment.
  • Crearte new environment with all dependencies

2๐Ÿ‘

I had moved around my virtual environment folder.so I moved it back where it was, worked for me.

๐Ÿ‘คClayton Sibanda

1๐Ÿ‘

I just uninstalled Django and reinstalled it:

pip3 uninstall Django

pip3 install Django

then migrated

0๐Ÿ‘

There could be some migration files remaining in the app when you tried the migrate command. First remove all migrations directories from all the modules. For other cases Nikhil Rane has covered it all.

0๐Ÿ‘

This works for me:

  • Remove the current virtual environment and create your new virtual environment.
  • Run this command in the project directory to remove all migration files โ€“
    find . -type d -name "__pycache__" -exec rm -rf "{}" \;
  • Remove database file .sqlite3
  • Now run the migrations using: python manage.py makemigrations
  • Migrate the migrations: python manage.py migrate

Basically, all the below steps are common and I think all have gone through these steps but if youโ€™re missing the first step i.e., to recreate the virtual environment then must give a try to it.

๐Ÿ‘คMayur Gupta

-2๐Ÿ‘

Go to folder testBolt -> migrations and remove 0001_initial py and pyc files.

Leave a comment