#21142: Referencing the User model and migrations
---------------------------------+-----------------------------
     Reporter:  mario.pfeifer@…  |      Owner:
         Type:  Bug              |     Status:  new
    Component:  Migrations       |    Version:  master
     Severity:  Normal           |   Keywords:  Migration, Auth
 Triage Stage:  Unreviewed       |  Has patch:  0
Easy pickings:  0                |      UI/UX:  0
---------------------------------+-----------------------------
 Hi,

 To verify this bug I use a very simple model in which I reference to the
 User model:

 {{{
 from django.conf import settings
 from django.db import models


 class Article(models.Model):
     name = models.CharField('Name', max_length=255)
     author = models.ForeignKey(settings.AUTH_USER_MODEL)
 }}}

 After running ./manage.py makemigrations everything looks fine:

 {{{
 Do you want to enable migrations for app 'articles'? [y/N] y
 Migrations for 'articles':
   0001_initial.py:
     - Create model Article
 }}}

 But running ./manage.py migrate runs into following error:

 {{{
 Traceback (most recent call last):
   File "./manage.py", line 10, in <module>
     execute_from_command_line(sys.argv)
   File "/home/mario/django-trunk/django/core/management/__init__.py", line
 397, in execute_from_command_line
     utility.execute()
   File "/home/mario/django-trunk/django/core/management/__init__.py", line
 390, in execute
     self.fetch_command(subcommand).run_from_argv(self.argv)
   File "/home/mario/django-trunk/django/core/management/base.py", line
 242, in run_from_argv
     self.execute(*args, **options.__dict__)
   File "/home/mario/django-trunk/django/core/management/base.py", line
 289, in execute
     output = self.handle(*args, **options)
   File "/home/mario/django-
 trunk/django/core/management/commands/migrate.py", line 88, in handle
     targets = executor.loader.graph.leaf_nodes()
   File "/home/mario/django-trunk/django/utils/functional.py", line 49, in
 __get__
     res = instance.__dict__[self.func.__name__] = self.func(instance)
   File "/home/mario/django-trunk/django/db/migrations/loader.py", line
 169, in graph
     graph.add_dependency(key, parent)
   File "/home/mario/django-trunk/django/db/migrations/graph.py", line 40,
 in add_dependency
     raise KeyError("Dependency references nonexistent parent node %r" %
 (parent,))
 KeyError: "Dependency references nonexistent parent node (u'auth',
 '0001_initial')"
 }}}

 The same happens when I directly reference to the User model:

 {{{
 from django.contrib.auth.models import User
 from django.db import models


 class Article(models.Model):
     name = models.CharField('Name', max_length=255)
     author = models.ForeignKey(User)
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/21142>
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/067.53c45777641f4415ec28cddf22f4a933%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to