#22325: Defining a custom user model in an app and having relations between it 
and
other models in the app causes circular dependencies
----------------------------+--------------------------------------
     Reporter:  melinath    |                    Owner:  nobody
         Type:  Bug         |                   Status:  new
    Component:  Migrations  |                  Version:  master
     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 nliberg):

 As far as I can see the error is in the `build_graph` method of the
 `MigrationLoader` class.
 The `self.graph.root_nodes(...)` method seems to be invoked before the
 graph is fully built resulting in some extra nodes in the returned set
 that are root nodes in the current partial graph but are not root nodes in
 the final graph. Since the parent of the dependency relationship is drawn
 from this set of nodes one can end up with an incorrect loop from the node
 to itself in the graph. This results in a CircularDependencyError
 exception at a later stage.

 The problem seem to be fixed by building the graph in two steps: first
 handling all normal nodes and then the `"__first__"` nodes (that get
 remapped to a root node). Someone with a deeper understanding of the
 relevant code will have to be the judge of whether this is a partial or
 complete fix. At least the patch above fixes the problem for me.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/22325#comment:2>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.68aa853f792418423d7cfd1c2a973148%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to