我试图将迁移应用于新数据库,但是我一直收到此错误,我删除了旧数据库中的所有迁移文件以及应用程序中的文件。当我尝试将迁移应用于新数据库或运行python manage.py runserver时,出现此错误..?我想知道可能是什么问题。正在使用Django 3.1.1
E:\All django project\Real-Estate-Django-Web-App-master>manage.py migrate
Traceback (most recent call last):
File "E:\All django project\Real-Estate-Django-Web-App-master\manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Python38\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python38\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Python38\lib\site-packages\django\core\management\base.py", line 371, in execute
output = self.handle(*args, **options)
File "C:\Python38\lib\site-packages\django\core\management\base.py", line 85, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Python38\lib\site-packages\django\core\management\commands\migrate.py", line 92, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "C:\Python38\lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "C:\Python38\lib\site-packages\django\db\migrations\loader.py", line 53, in __init__
self.build_graph()
File "C:\Python38\lib\site-packages\django\db\migrations\loader.py", line 255, in build_graph
self.graph.validate_consistency()
File "C:\Python38\lib\site-packages\django\db\migrations\graph.py", line 195, in validate_consistency
[n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
File "C:\Python38\lib\site-packages\django\db\migrations\graph.py", line 195, in <listcomp>
[n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
File "C:\Python38\lib\site-packages\django\db\migrations\graph.py", line 58, in raise_error
raise NodeNotFoundError(self.error_message, self.key, origin=self.origin)
django.db.migrations.exceptions.NodeNotFoundError: Migration auth.0013_user_following dependencies reference nonexistent parent node ('account', '0003_contact')
答案 0 :(得分:1)
好吧!我终于能够解决问题,方法是先在虚拟环境中卸载Django,然后重做安装,但是问题仍然存在,因此我按照直觉删除了整个虚拟环境,然后进行了virtualenv的安装。安装了Django,它运行完美。感谢所有尝试提供帮助的人,我非常感谢您的回答。
答案 1 :(得分:0)
auth.0013_user_following迁移需要0003_contact迁移,该迁移丢失。
尝试从所有应用中删除所有迁移并设置新数据库。
答案 2 :(得分:0)
根据 Abubakari UmarblacKrussain Uma 提供的解决方案,我注意到链接到我的虚拟环境文件的包丢失/损坏。当我对照我的 requirements.text 文件检查它时,我注意到 Django 包被 django 2.2.27(django 小写)替换,并添加了一个条目 -jango 3.1.3。我手动编辑了 requirements.txt 文件以删除 -jango 3.1.3 条目并用 Django 3.1.3 替换 django 2.2.27 并从 requirements.txt重新加载虚拟环境强>。这解决了错误。为了更好地衡量,我为虚拟环境重新生成了 requirements.txt 文件。