2016-04-15 50 views
4

我更新了django-dynamic-model存儲庫以支持Django 1.9。我得到這個錯誤:修復在Django1.9中檢測到的衝突遷移

CommandError: 

Conflicting migrations detected; multiple leaf nodes in the migration 
graph: (0001_initial, 0002_auto__add_field_dynamicschemafield_extra in 
dynamicmodel). 
To fix them run 'python manage.py makemigrations --merge' 

運行python manage.py makemigrations --merge後,我得到了另一個錯誤:

File "/local/lib/python2.7/sitepackages/django/core/management/__init__.py", 
line 353, in execute_from_command_line 
utility.execute() 

File "/local/lib/python2.7/sitepackages/django/core/management/__init__.py", line 345, in execute 
self.fetch_command(subcommand).run_from_argv(self.argv) 

File 
"/local/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv 
self.execute(*args, **cmd_options) 

File 
"/local/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute 
output = self.handle(*args, **options) 

File 
"/local/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py", line 97, in handle 
return self.handle_merge(loader, conflicts) 

File 
    "/local/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py", line 216, in handle_merge 
raise ValueError("Could not find common ancestor of %s" % migration_names) 


ValueError: Could not find common ancestor of set([u'0001_initial', u'0002_auto__add_field_dynamicschemafield_extra']). 

幫我找到解決方案。

回答

0

好像你注入了其他應用程序的模型。

在遷移中定義TARGET_APP,看起來像migrations loader無法正確識別目標應用程序。

+0

什麼是'TARGET_APP'?我使用的是Django 1.8,並嘗試在'--merge'之後明確給出應用程序名稱,但這並沒有幫助我看到 –

+1

,'TARGET_APP'是遷移文件中的變量,而不是遷移參數腳本https://stackoverflow.com/questions/29575802/django-migration-file-in-an-other-app –

0

的遷移需要有「直」依存關係鏈,即遷移0003需要靠移民0002,和技術在0001

您需要在0003_third.py這樣定義的:

class Migration(migrations.Migration): 
    dependencies = [ 
     ('modulename', '0002_second'), 
    ]