#33586: Applying RunPython backward results in ValueError when involved models 
are
referenced through multiple foreign keys
-------------------------------+------------------------------------
     Reporter:  Jeremy Poulin  |                    Owner:  (none)
         Type:  Bug            |                   Status:  new
    Component:  Migrations     |                  Version:  4.0
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Accepted
    Has patch:  1              |      Needs documentation:  0
  Needs tests:  1              |  Patch needs improvement:  1
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+------------------------------------
Comment (by Simon Charette):

 One thing that isn't clear to me if we go froward with this change is what
 purpose do `_find_reload_model(delay=True)` even has as if we now
 systematically get all models recursively later in the function. By that I
 ask what's the purpose of this branch

 {{{#!diff
 diff --git a/django/db/migrations/state.py b/django/db/migrations/state.py
 index 9e9cc58fae..3f8f10d601 100644
 --- a/django/db/migrations/state.py
 +++ b/django/db/migrations/state.py
 @@ -383,10 +383,7 @@ class ProjectState:
          else:
              # Get all relations to and from the old model before
 reloading,
              # as _meta.apps may change
 -            if delay:
 -                related_models = get_related_models_tuples(old_model)
 -            else:
 -                related_models = get_related_models_recursive(old_model)
 +            related_models = get_related_models_recursive(old_model)

          # Get all outgoing references from the model to be rendered
          model_state = self.models[(app_label, model_name)]
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/33586#comment:37>
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 view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019c336dea1e-f79c95eb-221a-45c3-9796-9fcf708a43e8-000000%40eu-central-1.amazonses.com.

Reply via email to