﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
22932	"""makemigrations"" generates circular dependencies"	Manuel Kaufmann	nobody	"I'm having an issue with the new migrations system included in Django. The steps that I'm following to reproduce is, once the example project is downloaded just run:

 1. manage.py makemigrations
 1. manage.py migrate

{{{
Traceback (most recent call last):
  File ""/home/humitos/Source/migration_test/manage.py"", line 10, in <module>
    execute_from_command_line(sys.argv)
  File ""/home/humitos/.virtualenvs/tmp-e997f5cc453b28eb/local/lib/python2.7/site-packages/django/core/management/__init__.py"", line 330, in execute_from_command_line
    utility.execute()
  File ""/home/humitos/.virtualenvs/tmp-e997f5cc453b28eb/local/lib/python2.7/site-packages/django/core/management/__init__.py"", line 322, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""/home/humitos/.virtualenvs/tmp-e997f5cc453b28eb/local/lib/python2.7/site-packages/django/core/management/base.py"", line 363, in run_from_argv
    self.execute(*args, **cmd_options)
  File ""/home/humitos/.virtualenvs/tmp-e997f5cc453b28eb/local/lib/python2.7/site-packages/django/core/management/base.py"", line 412, in execute
    output = self.handle(*args, **options)
  File ""/home/humitos/.virtualenvs/tmp-e997f5cc453b28eb/local/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py"", line 78, in handle
    loader.project_state(),
  File ""/home/humitos/.virtualenvs/tmp-e997f5cc453b28eb/local/lib/python2.7/site-packages/django/db/migrations/loader.py"", line 268, in project_state
    return self.graph.make_state(nodes=nodes, at_end=at_end, real_apps=list(self.unmigrated_apps))
  File ""/home/humitos/.virtualenvs/tmp-e997f5cc453b28eb/local/lib/python2.7/site-packages/django/db/migrations/graph.py"", line 140, in make_state
    for migration in self.forwards_plan(node):
  File ""/home/humitos/.virtualenvs/tmp-e997f5cc453b28eb/local/lib/python2.7/site-packages/django/db/migrations/graph.py"", line 55, in forwards_plan
    return self.dfs(node, lambda x: self.dependencies.get(x, set()))
  File ""/home/humitos/.virtualenvs/tmp-e997f5cc453b28eb/local/lib/python2.7/site-packages/django/db/migrations/graph.py"", line 121, in dfs
    return _dfs(start, get_children, [])
  File ""/home/humitos/.virtualenvs/tmp-e997f5cc453b28eb/local/lib/python2.7/site-packages/django/db/migrations/graph.py"", line 113, in _dfs
    results = _dfs(n, get_children, path) + results
  File ""/home/humitos/.virtualenvs/tmp-e997f5cc453b28eb/local/lib/python2.7/site-packages/django/db/migrations/graph.py"", line 113, in _dfs
    results = _dfs(n, get_children, path) + results
  File ""/home/humitos/.virtualenvs/tmp-e997f5cc453b28eb/local/lib/python2.7/site-packages/django/db/migrations/graph.py"", line 113, in _dfs
    results = _dfs(n, get_children, path) + results
  File ""/home/humitos/.virtualenvs/tmp-e997f5cc453b28eb/local/lib/python2.7/site-packages/django/db/migrations/graph.py"", line 105, in _dfs
    raise CircularDependencyError(path[path.index(start):] + [start])
django.db.migrations.graph.CircularDependencyError: [('challenge', u'0001_initial'), (u'team', u'0001_initial'), ('challenge', u'0001_initial')]
}}}

If I remove the {{{myapp.team.TeamCaptain}}} model and the migration files already created and I run those commands again, it creates the proper migration files and it works.

I've been taking a look at #22325 but it doesn't seem to be the same situation.

I tried this in Django 1.7b4, 1.7c1 and master and I always got the same error.

What other kind of information can I provide?"	Bug	closed	Migrations	dev	Normal	fixed	circular dependency, migrations, makemigrations	Manuel Kaufmann berto	Unreviewed	0	0	0	0	0	0
