Im getting Exception Node Not Found while doing migration.

Hello Guys,

Im just stuck with error while making migrations to my django project.
In my project which is already 50% dveloped i use owner model to represent owner of shop and then i used user model for login and for registration purpose.
So i tried to use user model in my owner model so i could utilise both model effectively with additional fields.
I tried to extend user model in owner model using onetoone field. after doing that i was not able to do migrations so i deleted all migrations files but after that it was start giving this error while doing migrations:-

py makemigrations
Traceback (most recent call last):
File “”, line 21, in
File “”, line 17, in main
File “C:\Users\Mayur\PycharmProjects\StartUp\venv\lib\site-packages\django\core\”, line 401, in execute_from_command_line
File “C:\Users\Mayur\PycharmProjects\StartUp\venv\lib\site-packages\django\core\”, line 395, in execute
File “C:\Users\Mayur\PycharmProjects\StartUp\venv\lib\site-packages\django\core\management\”, line 328, in run_from_argv
self.execute(*args, **cmd_options)
File “C:\Users\Mayur\PycharmProjects\StartUp\venv\lib\site-packages\django\core\management\”, line 369, in execute
output = self.handle(*args, **options)
File “C:\Users\Mayur\PycharmProjects\StartUp\venv\lib\site-packages\django\core\management\”, line 83, in wrapped
res = handle_func(*args, **kwargs)
File “C:\Users\Mayur\PycharmProjects\StartUp\venv\lib\site-packages\django\core\management\commands\”, line 87, in handle
loader = MigrationLoader(None, ignore_no_migrations=True)
File “C:\Users\Mayur\PycharmProjects\StartUp\venv\lib\site-packages\django\db\migrations\”, line 49, in init
File “C:\Users\Mayur\PycharmProjects\StartUp\venv\lib\site-packages\django\db\migrations\”, line 274, in build_graph
raise exc
File “C:\Users\Mayur\PycharmProjects\StartUp\venv\lib\site-packages\django\db\migrations\”, line 248, in build_graph
File “C:\Users\Mayur\PycharmProjects\StartUp\venv\lib\site-packages\django\db\migrations\”, line 195, in validate_consistency
[n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
File “C:\Users\Mayur\PycharmProjects\StartUp\venv\lib\site-packages\django\db\migrations\”, line 195, in
[n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
File “C:\Users\Mayur\PycharmProjects\StartUp\venv\lib\site-packages\django\db\migrations\”, line 58, in raise_error
raise NodeNotFoundError(self.error_message, self.key, origin=self.origin)
django.db.migrations.exceptions.NodeNotFoundError: Migration listings.0001_initial dependencies reference nonexistent parent node (‘owners’, ‘0001_initial’)

Here is My Owner Model Code:-

from django.db import models
from django.contrib.auth.models import User

class Owner(models.Model):
user = models.OneToOneField(User,on_delete=models.CASCADE, default=False)

def __str__(self):

I hope i will get working solution on this problem so i can move ahead in my project development.

1 Like

Your database tracks what migrations have previously been applied. When you delete the migration files, you’re breaking that connection between the files in your application and the database.

You may have some luck by emptying the django_migrations table and trying again. Unfortunately, if there are other migrations that have been previously applied, that may cause problems with other tables. (You can end up with migrations failing because the database changes have already been applied.)

You could try deleting all migration files again, empyting the django_migrations table, and retrying the migrations. That’s going to generate errors, usually of the type “something already exists”. At the top of the output, it’ll tell you which migration was being run. If you specifically run that migration with the --fake parameter, it’ll tell django that that migration was previously run and does not need to be reapplied. Do this enough times and you’ll be back to working.

The easier way is to just drop the database, recreate it, start from scratch, and realize that about the last thing you ever want to do is delete all your migration files…



you were right --fake with migration solved my problem.

1 Like