无法摆脱“不存在的父节点”在Django 1.11中 [英] Can't get rid of "nonexistent parent node" in django 1.11

查看:128
本文介绍了无法摆脱“不存在的父节点”在Django 1.11中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我已经尝试过互联网给我的所有解决方案,但仍然没有解决。

So far I've tried about anything the internet has given me on this problem and I still haven't solved it.

Python 3.6.1 -django 1.11.2-virtualenv

我有一个django项目,其中有两个应用程序 account app2 。最近,随着项目的发展,我决定将它们分成更合适的应用程序。现在我总共有8个应用程序,其中 account 分为 user_auth user ,然后我删除了帐户。为了整理得更多,我将所有应用程序从根文件夹移至 / apps /

Python 3.6.1 - django 1.11.2 - virtualenv
I had a django project with two apps account and app2. Recently I decided to split them up into more appropriate apps as the project is growing. Now I have a total of 8 apps where account got split up into user_auth and user, then I deleted account. To tidy it up even more I moved all apps from the root folder to /apps/.

到目前为止,只有 user,user_auth,app2 在使用中,而 app2 未被修改。

每个单独文件中的代码被拆分,移动到指定的应用程序并重新编码以从正确的路径中导入。

So far, only user, user_auth, app2 is in use where app2 has been untouched.
The code in each separate file was split up, moved to the designated app and recoded to get imports from the correct paths.

要重新开始,请删除db.sqlite3文件,并删除所有 *。pyc 文件,并删除所有 __ pycache __ 文件夹并清空 migrations 文件夹,确保保留所有 __ init __。py 文件。

To get a fresh start I delete the db.sqlite3 file, removed all *.pyc files, deleted all __pycache__ folders and emptied the migrations folders, making sure to keep all __init__.py files.

通过virtualenv运行 python manage.py migration 给我以下输出: / p>

Running python manage.py migrate through a virtualenv gives me this output:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
  File "H:\Programming\VirProjDir\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from_command_line
utility.execute()
  File "H:\Programming\VirProjDir\lib\site-packages\django\core\management\__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "H:\Programming\VirProjDir\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
  File "H:\Programming\VirProjDir\lib\site-packages\django\core\management\base.py", line 330, in execute
output = self.handle(*args, **options)
  File "H:\Programming\VirProjDir\lib\site-packages\django\core\management\commands\migrate.py", line 83, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "H:\Programming\VirProjDir\lib\site-packages\django\db\migrations\executor.py", line 20, in __init__
self.loader = MigrationLoader(self.connection)
  File "H:\Programming\VirProjDir\lib\site-packages\django\db\migrations\loader.py", line 52, in __init__
self.build_graph()
  File "H:\Programming\VirProjDir\lib\site-packages\django\db\migrations\loader.py", line 274, in build_graph
raise exc
  File "H:\Programming\VirProjDir\lib\site-packages\django\db\migrations\loader.py", line 244, in build_graph
self.graph.validate_consistency()
  File "H:\Programming\VirProjDir\lib\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 "H:\Programming\VirProjDir\lib\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 "H:\Programming\VirProjDir\lib\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 auth.0009_user_following dependencies reference nonexistent parent node ('account', '0002_contact')

到目前为止,我对这些命令没有运气,请确保删除以下所有缓存和* .pyc文件:

So far, I've had no luck with these commands, making sure to remove all cached and *.pyc files inbetween:

python manage.py migrate
python manage.py makemigrations
python manage.py makemigrations <app_name>
python manage.py flush
python manage.py --fake
python manage.py --fake <app_name> zero
etc..

我不明白为什么( 'account','0002_contact')一直显示,即使我删除了与我的代码没有直接关系的任何内容。

包含文本的搜索显示没有帐户曾经如此。

I don't get why ('account', '0002_contact') keeps showing up even tho I've deleted about anything that's not directly related to my code.
A "containing text"-search reveals no account what so ever.

任何想法下一个地方在哪里?

Any idea where to look next?

推荐答案

显然django保留了自己的模块文件夹中的迁移文件。这就是我所做的:

Apparently django kept migration files within it's own module folder. This is what I did:


  1. pip卸载django

  2. / Lib / site-packages ,已删除 django 文件夹。

  3. 删除我项目中的所有 *。pyc 文件。

  4. 删除所有 __ pycache __
  5. 清除了项目中的所有个迁移文件夹(保持 __ init__。 py )。

  6. pip install django == xxx

  7. python manage.py migration

  8. python manage.py makemigrations< app_name>

  9. python manage.py migration

  10. python manage.py runserver

  11. 庆祝。

  1. pip uninstall django.
  2. /Lib/site-packages, deleted django folder.
  3. Deleted all *.pyc files in my project.
  4. Deleted all __pycache__ folders in my project.
  5. Cleared all migrations folders in my project (keep __init__.py).
  6. pip install django==x.x.x.
  7. python manage.py migrate.
  8. python manage.py makemigrations <app_name>.
  9. python manage.py migrate.
  10. python manage.py runserver.
  11. Celebrate.

这篇关于无法摆脱“不存在的父节点”在Django 1.11中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆