Django django.db.migrations.graph.CircularDependencyError

夙愿已清 提交于 2020-01-17 04:08:27

问题


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

回答1:


I may suggest that you are trying to use ManyToMany field with 'through' option.

To fix it you need to do the next:

  1. Comment a whole line where you use ManyToMany+through by putting # at the beginning of the line
  2. makemigrations of_all_apps_you_need (also the one where the line from p1 exist)
  3. uncomment the line from p1
  4. makemigrations the_app_where_the_line_from_p1_exist
  5. migrate


来源:https://stackoverflow.com/questions/29003672/django-django-db-migrations-graph-circulardependencyerror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!