2015-11-12 95 views
2

Django verstion 1.8Django遷移錯誤 - NodeNotFoundError

嘗試遷移項目中新添加的應用程序。以下是回溯錯誤:

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') 

我在研究這方面沒有找到太多有用的信息。語法在所有模型中都是正確的。這是沒有道理的:這只是一個工作項目的副本。所以它可以在一臺電腦上運行,但不在這裏。它引用的機器模型已經創建並正在工作。有任何想法嗎???

+0

是否需要的遷移文件'機/遷移/ 0006_auto_20150921_1327.py'存在嗎? – Alasdair

+0

,我不認爲它...我使用Django的是舊版的,從來沒有之前創建遷移文件,所以我不知道這是不是「新」與否。這是我無論如何... :)現在研究它和整個同樣的事情來 - 不必創建遷移文件。 – Nicoale

回答

3

您正在收到錯誤,因爲您嘗試運行的遷移weather.0001_initial取決於不存在的遷移machines.0006_auto_20150921_1327

如果找不到缺失的遷移文件,則必須刪除並重新創建weather應用程序的遷移,以便它們不依賴於缺少的遷移。

+0

這正是我不得不這樣做。遷移目錄已創建。所以我刪除它並運行遷移。新的遷移能夠得到處理,現在一切正常。謝謝!!! – Nicoale