问题
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:
- 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
来源:https://stackoverflow.com/questions/29003672/django-django-db-migrations-graph-circulardependencyerror