在django中迁移时,依赖项引用不存在的父节点错误

时间:2016-12-06 10:23:02

标签: python django

我正在做一个项目,当我尝试在django中迁移时,错误来了

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 346, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 394, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 445, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/makemigrations.py", line 63, in handle
    loader = MigrationLoader(None, ignore_no_migrations=True)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 47, in __init__
    self.build_graph()
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 321, in build_graph
    _reraise_missing_dependency(migration, parent, e)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 291, in _reraise_missing_dependency
    raise exc
django.db.migrations.graph.NodeNotFoundError: Migration reviews.0001_initial dependencies reference nonexistent parent node (u'catalogue', u'0001_initial')

我理解这个问题但无法解决。

我删除了所有.pyc文件和迁移文件夹。

我也删除了数据库,但这个问题仍然存在。 我怎样才能摆脱这个错误。 提前谢谢。

1 个答案:

答案 0 :(得分:-2)

从app中删除迁移文件夹,同时删除数据库并再次创建数据库。然后尝试:

  1. 1)python manage.py makemigrations
  2. 2)python manage.py migrate