请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

运行 makemigrations 时报错

manage.py@MxShop > makemigrations
"C:\Program Files\JetBrains\PyCharm 2018.2.4\bin\runnerw.exe" D:\Envs\MxShop\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm 2018.2.4\helpers\pycharm\django_manage.py" makemigrations C:/Users/huang/PycharmProjects/MxShop
Tracking file by folder pattern:  migrations
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2018.2.4\helpers\pycharm\django_manage.py", line 52, in <module>
    run_command()
  File "C:\Program Files\JetBrains\PyCharm 2018.2.4\helpers\pycharm\django_manage.py", line 46, in run_command
    run_module(manage_file, None, '__main__', True)
  File "C:\Users\huang\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "C:\Users\huang\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Users\huang\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:/Users/huang/PycharmProjects/MxShop\manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "D:\Envs\MxShop\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "D:\Envs\MxShop\lib\site-packages\django\core\management\__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "D:\Envs\MxShop\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "D:\Envs\MxShop\lib\site-packages\django\core\management\base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "D:\Envs\MxShop\lib\site-packages\django\core\management\commands\makemigrations.py", line 96, in handle
    loader = MigrationLoader(None, ignore_no_migrations=True)
  File "D:\Envs\MxShop\lib\site-packages\django\db\migrations\loader.py", line 52, in __init__
    self.build_graph()
  File "D:\Envs\MxShop\lib\site-packages\django\db\migrations\loader.py", line 274, in build_graph
    raise exc
  File "D:\Envs\MxShop\lib\site-packages\django\db\migrations\loader.py", line 244, in build_graph
    self.graph.validate_consistency()
  File "D:\Envs\MxShop\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 "D:\Envs\MxShop\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 "D:\Envs\MxShop\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 users.0001_initial dependencies reference nonexistent parent node ('auth', '0009_alter_user_last_name_max_length')

Process finished with exit code 1

正在回答

1回答

这个应该是makemigartions混乱造成的 ,你可以安装这个步骤来:

  1. 通过navicat删除所有的表

  2. 删除所有app下面的makemigrations目录下的所有文件(不能删除__init__.py文件)

  3. 重新makemigrations和migrate

1 回复 有任何疑惑可以回复我~
  • 提问者 慕妹4270370 #1
    非常感谢!老师太厉害了
    回复 有任何疑惑可以回复我~ 2018-11-24 16:03:26
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信