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

编程入门 行业动态 更新时间:2024-10-27 17:14:39
本文介绍了修复在Django1.9中检测到的冲突迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我更新了 django-dynamic-model 存储库以支持Django 1.9。我收到此错误:

I updated django-dynamic-model repository to support Django 1.9. I got this error:

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 ,出现另一个错误:

After running python manage.py makemigrations --merge, I got another error:

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。

The migrations need to have "straight" dependency chain, i.e. migration 0003 needs to depend on migration 0002, and 0002 on 0001.

您需要在0003_third.py中定义如下:

You need to define this in the 0003_third.py like this:

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

更多推荐

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

本文发布于:2023-11-15 06:41:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1592050.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:检测到   冲突

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!