#23360: CircularDependencyError with AUTH_USER_MODEL set
-------------------------------+--------------------------------------
     Reporter:  brian          |                    Owner:  nobody
         Type:  Uncategorized  |                   Status:  new
    Component:  Migrations     |                  Version:  1.7-rc-3
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------

Comment (by brian):

 Sooo guardian.testapp.models.py has:

 {{{
 from django.contrib.admin.models import LogEntry

 class LogEntryWithGroup(LogEntry):
     group = models.ForeignKey('auth.Group', null=True, blank=True)
 }}}

 This means testapp depends on admin, because it requires LogEntry.

 django.contrib.admin.models has:

 {{{
 class LogEntry(models.Model):
     user = models.ForeignKey(settings.AUTH_USER_MODEL)
 }}}

 This means that admin depends on testapp, because settings.AUTH_USER_MODEL
 == "testapp.CustomUser".  Or:

 admin.LogEntry --> testapp.CustomUser
 testapp.LogEntryWithGroup --> admin.LogEntry

 Which clearly shows the circular dependency.

 I was wondering what happens if you have two apps containing two models
 that depend on each other, think it isn't going to work. You could make
 the argument this was never really supported - in Django 1.6/South I have
 had problems with a similar situation with postgresql requiring the other
 table to be created before constraints are created, however it gave the
 illusion of working, at least for mysql.

 In this particular case, wonder if might be possible to split the
 migration up into two. So that `('testapp', '0001_initial')` creates
 `CustomUser`, admin depends on this, then `('testapp',
 '0002_LogEntryWithGroup')` creates `LogEntryWithGroup` and depends on
 admin. Might have a play at this later.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/23360#comment:5>
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/063.16ac39e5eef3c3888156f14815d06735%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to