#24505: Multiple ManyToManyFields to same "to" model with related_name set to
'+'
mix up badly
-------------------------------------+-------------------------------------
Reporter: gergelypolonkai | Owner:
| marcofucci
Type: Bug | Status: assigned
Component: Database layer | Version: 1.7
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by marcofucci):
PR: https://github.com/django/django/pull/4382
"This fixes a bug with multiple many to many fields to the same to model
and related_name set to +.
This happens because Django is still using backwards relations internally
so multiple fields with the same related_name are sometimes overridden and
the last field defined wins.
There is still a bug with Django not throwing an exception when defining
m2m fields with the same related_name and backwards relation enabled but I
think it's slightly different from this one and should be managed
differently.
Ideally we would refactor the ORM so that it doesn't use backwards
relations internally when disabled but this particular fix was easy to
implement (although hard to find) so I would be happy with it.
I had to change a few tests so I would like somebody to take a look at
them and double-check that it makes sense if possible."
Thanks to Marc Tamlyn for the help and bmispelon for the TestCase.
--
Ticket URL: <https://code.djangoproject.com/ticket/24505#comment:3>
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/073.a2b29c4365fe99da7406e4b7de93efd1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.