Django迁移错误 - NodeNotFoundError

时间:2015-11-12 16:07:45

标签: django django-migrations

Django第1.8节

尝试在我的项目中迁移新添加的应用。这是回溯错误:

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 318, in build_graph
    _reraise_missing_dependency(migration, parent, e)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 288, in _reraise_missing_dependency
    raise exc
django.db.migrations.graph.NodeNotFoundError: Migration weather.0001_initial dependencies reference nonexistent parent node (u'machines', u'0006_auto_20150921_1327')

我在研究这方面没有找到太多有用的信息。语法在所有模型中都是正确的。这是没有意义的:这只是一个工作项目的副本。所以它可以在一台计算机上运行,​​但不在这里。机器模型的引用已经创建并且正在工作。有任何想法吗???

1 个答案:

答案 0 :(得分:6)

您收到错误是因为您尝试迁移的迁移machines.0006_auto_20150921_1327取决于不存在的迁移weather

如果找不到丢失的迁移文件,则必须删除并重新创建a = [0, 1, 0, 0, 0] b = [0, 0, 0, 1, 0] a_number = a.join.to_i(2) b_number = b.join.to_i(2) c_number = a_number | b_number c_array = c_number.to_s(2).split('').map(&:to_i) c_array = [0] * (a.size - c_array.size) + c_array if c_array.size < a.size p c_number.to_s(2) p c_array 应用的迁移,以便它们不依赖于丢失的迁移。