#22542: Migrations introduce circular dependency on custom user model
----------------------------+------------------------
Reporter: hoha@… | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-beta-2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------
It appears that a custom user model which inherits from another model
which has foreign keys to the user model, will fail when the migration is
run, due to a circular dependency. This code works just fine under Django
1.6 syncdb or South for that matter. The code fails both when the base
class is abstract and if not (making it abstract produces an extra
migration file though).
Attached is a model file with a custom user model implemented (and set as
the AUTH_MODEL in settings).
When makemigrations is run, three migrations are created. Upon appliance
it fails with the following traceback:
{{{
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/henrik/dj17b3/venv/lib/python3.4/site-
packages/django/core/management/__init__.py", line 427, in
execute_from_command_line
utility.execute()
File "/Users/henrik/dj17b3/venv/lib/python3.4/site-
packages/django/core/management/__init__.py", line 419, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/henrik/dj17b3/venv/lib/python3.4/site-
packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/henrik/dj17b3/venv/lib/python3.4/site-
packages/django/core/management/base.py", line 337, in execute
output = self.handle(*args, **options)
File "/Users/henrik/dj17b3/venv/lib/python3.4/site-
packages/django/core/management/commands/migrate.py", line 103, in handle
plan = executor.migration_plan(targets)
File "/Users/henrik/dj17b3/venv/lib/python3.4/site-
packages/django/db/migrations/executor.py", line 36, in migration_plan
backwards_plan = self.loader.graph.backwards_plan(target)[:-1]
File "/Users/henrik/dj17b3/venv/lib/python3.4/site-
packages/django/db/migrations/graph.py", line 64, in backwards_plan
return self.dfs(node, lambda x: self.dependents.get(x, set()))
File "/Users/henrik/dj17b3/venv/lib/python3.4/site-
packages/django/db/migrations/graph.py", line 119, in dfs
return _dfs(start, get_children, [])
File "/Users/henrik/dj17b3/venv/lib/python3.4/site-
packages/django/db/migrations/graph.py", line 111, in _dfs
results = _dfs(n, get_children, path) + results
File "/Users/henrik/dj17b3/venv/lib/python3.4/site-
packages/django/db/migrations/graph.py", line 111, in _dfs
results = _dfs(n, get_children, path) + results
File "/Users/henrik/dj17b3/venv/lib/python3.4/site-
packages/django/db/migrations/graph.py", line 103, in _dfs
raise CircularDependencyError(path[path.index(start):] + [start])
django.db.migrations.graph.CircularDependencyError: [('accounts',
'0001_initial'), ('accounts', '0001_initial')]
}}}
Tested in Django 1.7b3 (not available to choose in the version list).
Personally I'd consider this a release blocker; the functionality worked
as expected in Django 1.6. I will let you guys decide on the severity
though, obviously.
--
Ticket URL: <https://code.djangoproject.com/ticket/22542>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/060.ff7479683d7172f09d292ae7b44b65b8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.