#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 Jacob Walls):
From the hint on #36161, I was able to solve this in an affected project
like:
{{{#!diff
diff --git a/django/db/migrations/state.py b/django/db/migrations/state.py
index 9e9cc58fae..2eecb640bf 100644
--- a/django/db/migrations/state.py
+++ b/django/db/migrations/state.py
@@ -410,10 +410,7 @@ class ProjectState:
except LookupError:
pass
else:
- if delay:
-
related_models.update(get_related_models_tuples(rel_model))
- else:
-
related_models.update(get_related_models_recursive(rel_model))
+
related_models.update(get_related_models_recursive(rel_model))
# Include the model itself
related_models.add((app_label, model_name))
}}}
Notice the comment just above this says "For all direct related models
recursively get all related models." So, with this proposal, we really
''would'' be getting all recursive models.
Does this look promising?
--
Ticket URL: <https://code.djangoproject.com/ticket/33586#comment:36>
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/0107019c335a393b-21c3651f-0176-401d-9c3d-cce61d556794-000000%40eu-central-1.amazonses.com.