gpt4 book ai didi

python - 修复在 Django1.9 中检测到的迁移冲突

转载 作者:太空狗 更新时间:2023-10-29 21:58:12 24 4
gpt4 key购买 nike

我更新了django-dynamic-model支持 Django 1.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']).

帮我找到解决方案。

最佳答案

迁移需要有“直的”依赖链,即迁移 0003 需要依赖于迁移 0002,而 0002 需要依赖于 0001。

您需要在 0003_third.py 中这样定义它:

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

关于python - 修复在 Django1.9 中检测到的迁移冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36656495/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com