Django: dependencies reference nonexistent parent node creating a custom user
I am learning Django this is just a personal and local project. In the middle of development I decided to change my user to a CustomUser that I created with AbstractUser.
When typing
python manage.py makemigrate
I got this error:
Traceback (most recent call last):
File "/Users/pauleera/Documents/Diplomado /Ejemplos Python/Django/projects/pettry save money/pettry_project/manage.py", line 22, in <module>
main()
File "/Users/pauleera/Documents/Diplomado /Ejemplos Python/Django/projects/pettry save money/pettry_project/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/Users/pauleera/miniconda3/envs/work/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/Users/pauleera/miniconda3/envs/work/lib/python3.10/site-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/pauleera/miniconda3/envs/work/lib/python3.10/site-packages/django/core/management/base.py", line 416, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/pauleera/miniconda3/envs/work/lib/python3.10/site-packages/django/core/management/base.py", line 460, in execute
output = self.handle(*args, **options)
File "/Users/pauleera/miniconda3/envs/work/lib/python3.10/site-packages/django/core/management/base.py", line 107, in wrapper
res = handle_func(*args, **kwargs)
File "/Users/pauleera/miniconda3/envs/work/lib/python3.10/site-packages/django/core/management/commands/makemigrations.py", line 140, in handle
loader = MigrationLoader(None, ignore_no_migrations=True)
File "/Users/pauleera/miniconda3/envs/work/lib/python3.10/site-packages/django/db/migrations/loader.py", line 58, in __init__
self.build_graph()
File "/Users/pauleera/miniconda3/envs/work/lib/python3.10/site-packages/django/db/migrations/loader.py", line 276, in build_graph
self.graph.validate_consistency()
File "/Users/pauleera/miniconda3/envs/work/lib/python3.10/site-packages/django/db/migrations/graph.py", line 198, in validate_consistency
[n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
File "/Users/pauleera/miniconda3/envs/work/lib/python3.10/site-packages/django/db/migrations/graph.py", line 198, in <listcomp>
[n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
File "/Users/pauleera/miniconda3/envs/work/lib/python3.10/site-packages/django/db/migrations/graph.py", line 60, in raise_error
raise NodeNotFoundError(self.error_message, self.key, origin=self.origin)
django.db.migrations.exceptions.NodeNotFoundError: Migration auth.0013_user_favorites dependencies reference nonexistent parent node ('products', '0002_alter_productprice_price_favoriteproduct')
** I have already deleted migrations files, also the db.sqlite3 file** Can you help me to solve it? I don't want to redo it :'(
thanks
I think you're getting this error because a migration is referencing a missing migration:
('products', '0002_alter_productprice_price_favoriteproduct')
.
So try to:
- Delete all migration files except
__init__.py
:
macOS/Linux:
find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
Windows (Command Prompt or PowerShell):
del /S /Q */migrations\*.py
(Then recreate the empty
__init__.py
in eachmigrations/
folder if needed)
- Delete compiled files and
__pycache__
:
macOS/Linux:
find . -name "*.pyc" -delete find . -name "__pycache__" -type d -exec rm -r {} +
Windows:
for /r %i in (*.pyc) do del "%i" for /d /r . %d in (__pycache__) do @if exist "%d" rd /s /q "%d"
then run makemigrations and migrate commands