{{{
ManyToManyField(to=Group, related_name='+')
}}}
Now when I add a group to fillable_by and another one to approvable_by,
the fillable_by gets overridden by approvable_by. I cannot find anything
related to this in the documentation, but it seems a pretty bad behaviour
to me.
The problem still exists in latest 1.7.7 version.
--
Ticket URL: <https://code.djangoproject.com/ticket/24505>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted
Comment:
Hi,
I can confirm that something strange is going on.
I'm attaching a testcase patch to reproduce the issue.
Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/24505#comment:1>
* Attachment "issue24505_testcase.diff" added.
Reproduction testcase
* owner: nobody => marcofucci
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/24505#comment:2>
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>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/24505#comment:4>
Comment (by marcofucci):
I did a bit of research after `jtiai` pointed me in the right direction
and it seems that we've had the same problem before.
To fix the problem, we documented a workaround where `related_name`s had
to be unique, even the ones ending in `+` #15932.
We then thought we had fixed it in #21375 so we deleted the documented
workaround #21491.
Finally, it seems that the bug is back and addressed here.
--
Ticket URL: <https://code.djangoproject.com/ticket/24505#comment:5>
* needs_better_patch: 0 => 1
Comment:
Patch needs a rebase.
--
Ticket URL: <https://code.djangoproject.com/ticket/24505#comment:6>
* needs_better_patch: 1 => 0
Comment:
Rebased
--
Ticket URL: <https://code.djangoproject.com/ticket/24505#comment:7>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"4ee08958f154594b538207a53c1d457687b3f7ae" 4ee08958]:
{{{
#!CommitTicketReference repository=""
revision="4ee08958f154594b538207a53c1d457687b3f7ae"
Fixed #24505 -- Fixed clash with hidden m2m fields.
Added support for multiple m2m fields with the same 'to' model
and with related_name set to '+'.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24505#comment:8>
* cc: jeroen@… (added)
Comment:
I just hit this bug with 1.8 and spend a lot of time to figure out what
was going on. Given that the fix is pretty trivial, would it be possible
to backport it to 1.8?
--
Ticket URL: <https://code.djangoproject.com/ticket/24505#comment:9>
Comment (by timgraham):
If you'd like to send a pull request, I'll merge it. Please include a
mention in the 1.8.3 release notes.
--
Ticket URL: <https://code.djangoproject.com/ticket/24505#comment:10>
Comment (by Tim Graham <timograham@…>):
In [changeset:"0e2d3b93043676975aa921a70b5faafef02cac5c" 0e2d3b9]:
{{{
#!CommitTicketReference repository=""
revision="0e2d3b93043676975aa921a70b5faafef02cac5c"
[1.8.x] Fixed #24505 -- Fixed clash with hidden m2m fields.
Added support for multiple m2m fields with the same 'to' model
and with related_name set to '+'.
Backport of 4ee08958f154594b538207a53c1d457687b3f7ae from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24505#comment:11>
Comment (by Tim Graham <timograham@…>):
In [changeset:"061801e3dfb3f88550cdaeef1a6dd1c24c13d53d" 061801e3]:
{{{
#!CommitTicketReference repository=""
revision="061801e3dfb3f88550cdaeef1a6dd1c24c13d53d"
Refs #24505 -- Forwardported 1.8.5 release note.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24505#comment:12>
Comment (by Tim Graham <timograham@…>):
In [changeset:"3569e9d4a1e03b46b2649ca1d4fcdf9b72c552d1" 3569e9d4]:
{{{
#!CommitTicketReference repository=""
revision="3569e9d4a1e03b46b2649ca1d4fcdf9b72c552d1"
[1.9.x] Refs #24505 -- Forwardported 1.8.5 release note.
Backport of 061801e3dfb3f88550cdaeef1a6dd1c24c13d53d from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24505#comment:13>