Django django.db.migrations.graph.CircularDependencyError [英] Django django.db.migrations.graph.CircularDependencyError
本文介绍了Django django.db.migrations.graph.CircularDependencyError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在迁移应用程序时遇到发行错误。
运行此命令时:
I am facing circulation error while migrating my app. when i run this:
(virEnv)abc@abc-All-Series:~/vissa_poc$ python manage.py migrate forms
**I get this:**
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/abc/virEnv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/abc/virEnv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/abc/virEnv/local/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/abc/virEnv/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/home/abc/virEnv/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 106, in handle
plan = executor.migration_plan(targets)
File "/home/abc/virEnv/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 54, in migration_plan
for migration in self.loader.graph.forwards_plan(target):
File "/home/abc/virEnv/local/lib/python2.7/site-packages/django/db/migrations/graph.py", line 60, in forwards_plan
return self.dfs(node, lambda x: self.dependencies.get(x, set()))
File "/home/abc/virEnv/local/lib/python2.7/site-packages/django/db/migrations/graph.py", line 124, in dfs
self.ensure_not_cyclic(start, get_children)
File "/home/abc/virEnv/local/lib/python2.7/site-packages/django/db/migrations/graph.py", line 112, in ensure_not_cyclic
raise CircularDependencyError(", ".join("%s.%s" % n for n in cycle))
django.db.migrations.graph.CircularDependencyError: vissa.0001_initial, forms.0001_initial
推荐答案
我建议您尝试使用通过选项的ManyToMany字段。
I may suggest that you are trying to use ManyToMany field with 'through' option.
要修复此问题,您需要执行下一个操作:
To fix it you need to do the next:
- Comme在整行中,您可以通过在行的开头加上#来使用ManyToMany +,
- makemigrations of_all_apps_you_need(也是p1行所在的行)
- 取消注释p1中的行
- makemigrations the_app_where_the_line_from_p1_exist
- migrate
- Comment a whole line where you use ManyToMany+through by putting # at the beginning of the line
- makemigrations of_all_apps_you_need (also the one where the line from p1 exist)
- uncomment the line from p1
- makemigrations the_app_where_the_line_from_p1_exist
- migrate
这篇关于Django django.db.migrations.graph.CircularDependencyError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文