'Django Allauth migration error
I've run across this issue before and I think I had to go into the library installed by pip to manually delete the migrations to fix it. Does anyone have a better idea?
./manage.py makemigrations
Traceback (most recent call last):
File "./manage.py", line 23, in <module>
execute_from_command_line(sys.argv)
File "/Users/josh/.pyenv/versions/one_raft_first_site/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/Users/josh/.pyenv/versions/one_raft_first_site/lib/python3.5/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/josh/.pyenv/versions/one_raft_first_site/lib/python3.5/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/josh/.pyenv/versions/one_raft_first_site/lib/python3.5/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/Users/josh/.pyenv/versions/one_raft_first_site/lib/python3.5/site-packages/django/core/management/commands/makemigrations.py", line 95, in handle
loader = MigrationLoader(None, ignore_no_migrations=True)
File "/Users/josh/.pyenv/versions/one_raft_first_site/lib/python3.5/site-packages/django/db/migrations/loader.py", line 52, in __init__
self.build_graph()
File "/Users/josh/.pyenv/versions/one_raft_first_site/lib/python3.5/site-packages/django/db/migrations/loader.py", line 268, in build_graph
raise exc
File "/Users/josh/.pyenv/versions/one_raft_first_site/lib/python3.5/site-packages/django/db/migrations/loader.py", line 238, in build_graph
self.graph.validate_consistency()
File "/Users/josh/.pyenv/versions/one_raft_first_site/lib/python3.5/site-packages/django/db/migrations/graph.py", line 261, in validate_consistency
[n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
File "/Users/josh/.pyenv/versions/one_raft_first_site/lib/python3.5/site-packages/django/db/migrations/graph.py", line 261, in <listcomp>
[n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
File "/Users/josh/.pyenv/versions/one_raft_first_site/lib/python3.5/site-packages/django/db/migrations/graph.py", line 104, in raise_error
raise NodeNotFoundError(self.error_message, self.key, origin=self.origin)
django.db.migrations.exceptions.NodeNotFoundError: Migration socialaccount.0001_initial dependencies reference nonexistent parent node ('sites', '0001_initial')
Solution 1:[1]
The problem with your code is that django.contrib.sites
is not present in your INSTALLED_APPS
. This package is a direct dependency of the allauth
package.
It is referenced in the installation section of the documentation:
settings.py (Important - Please note ‘django.contrib.sites’ is required as INSTALLED_APPS)
and your error says that explicitly:
Migration socialaccount.0001_initial dependencies reference nonexistent parent node ('sites', '0001_initial')
Solution 2:[2]
Very likely the problem occurred because you have defined settings.MIGRATION_MODULES
setting for the sites
app. And the module doesn't have all the necessary migrations on which allauth
relies.
There are two solutions.
- Copy migrations from
$PYTHON_HOME/site-packages/django/contrib/sites/migrations
to the folder which is specified in your settings. - Remove
sites
from that setting.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Volodymyr Piskun |