进行模型更改时,Django 依赖项引用不存在的父节点
Posted
技术标签:
【中文标题】进行模型更改时,Django 依赖项引用不存在的父节点【英文标题】:Django dependencies reference nonexistent parent node when making model changes 【发布时间】:2019-12-17 06:24:24 【问题描述】:我在 aws 服务器上部署了一个 Django 项目。我在我的机器上对模型进行了一些更改,并通过 Github 推送了更改,在服务器上,我通过 git 命令提取了更改,但应用程序无法正常工作,所以当我尝试运行 python manage.py makemigrations
它返回错误
类似于 Django:依赖项引用不存在的父节点
我尝试删除错误中提到的文件并尝试删除 .pyc
文件,但仍然是同样的问题,所以我可以在这里做什么以及将来应该如何做以避免这些问题。
这是回溯
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/core/management/commands/makemigrations.py", line 89, in handle
loader = MigrationLoader(None, ignore_no_migrations=True)
File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/db/migrations/loader.py", line 273, in build_graph
raise exc
File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/db/migrations/loader.py", line 247, in build_graph
self.graph.validate_consistency()
File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/db/migrations/graph.py", line 243, in validate_consistency
[n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/db/migrations/graph.py", line 243, in <listcomp>
[n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/db/migrations/graph.py", line 96, in raise_error
raise NodeNotFoundError(self.error_message, self.key, origin=self.origin)
django.db.migrations.exceptions.NodeNotFoundError: Migration patients.0007_uploadedimages_processed_image dependencies reference nonexistent parent node ('patients', '0006_auto_20190803_2241')
更新:不是整个应用程序无法运行,而是新/更改模型的视图返回 500 内部服务器错误。
【问题讨论】:
您似乎忘记了添加、提交和推送较旧的迁移文件:0006_auto_20190803_2241 我发现从 0001 到 0006 丢失了你建议如何添加这些?我应该添加所有这些吗? 【参考方案1】:我必须手动复制每个依赖项并粘贴其内容。从 0001 到 0006。
【讨论】:
以上是关于进行模型更改时,Django 依赖项引用不存在的父节点的主要内容,如果未能解决你的问题,请参考以下文章
在 INSTALLED_APPS 中添加“pinax.notifications”后出现“依赖项引用不存在的父节点”错误