NIKHIL RANE NIKHIL RANE - 1 year ago 264
Python Question

Django: dependencies reference nonexistent parent node

When I run the following command

python migrate

I receive this error from django so can't step forward in my practice:

Traceback (most recent call last):
File "", line 10, in <module>
File "/home/nikhil/testWeb-devEnv/local/lib/python2.7/site-packages/django/core/management/", line 385, in execute_from_command_line
File "/home/nikhil/testWeb-devEnv/local/lib/python2.7/site-packages/django/core/management/", line 377, in execute
File "/home/nikhil/testWeb-devEnv/local/lib/python2.7/site-packages/django/core/management/", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/nikhil/testWeb-devEnv/local/lib/python2.7/site-packages/django/core/management/", line 338, in execute
output = self.handle(*args, **options)
File "/home/nikhil/testWeb-devEnv/local/lib/python2.7/site-packages/django/core/management/commands/", line 63, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "/home/nikhil/testWeb-devEnv/local/lib/python2.7/site-packages/django/db/migrations/", line 17, in __init__
self.loader = MigrationLoader(self.connection)
File "/home/nikhil/testWeb-devEnv/local/lib/python2.7/site-packages/django/db/migrations/", line 48, in __init__
File "/home/nikhil/testWeb-devEnv/local/lib/python2.7/site-packages/django/db/migrations/", line 241, in build_graph
self.graph.add_dependency(migration, key, parent)
File "/home/nikhil/testWeb-devEnv/local/lib/python2.7/site-packages/django/db/migrations/", line 42, in add_dependency
raise KeyError("Migration %s dependencies reference nonexistent parent node %r" % (migration, parent))
KeyError: u"Migration testBolt.0001_initial dependencies reference nonexistent parent node (u'delivery_boy', u'0004_auto_20150221_2011')"

How do I solve this problem?

Answer Source

Solution - 1

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

Solution - 2

  1. Remove the new changes from the modals and run python migrate --fake

  2. Now again modify your models with new changes

  3. Run python makemigrations

  4. And then again run python migrate

Solution - 3

Remove pyc files from your migrations folder.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download