Hi Nadège, Sorry for the delay. Yeah, when I was working on PR 8981, I ran into the symmetrical case and wasn't sure what the behavior should be, so I left the check in place to not allow the behavior. I asked my self the same question you did about possibly needing "through_reverse_defaults" and didn't have answer. I also didn't have a use-case for symmetrical with intermediary/through. I wasn't sure about other unintended consequences and just wanted to get the rest of the change out the door.
If you think "both objects should have the same value" then I'd say go for it. I suppose it does make sense considering it's supposed to be symmetrical as you said. If later people want through_reverse_defaults we could always add it later. Thanks, Collin On Tuesday, April 23, 2019 at 8:13:35 AM UTC-4, Nadège Michel wrote: > > Hello, > > We use self.referencing ManyToMany relationships with intermediate tables > in our work project > and I was wondering why we had to create ourselves the reverse link when > we need the relationship to be symmetrical. > I looked at the 'symmetrical' attribute documentation and though we should > just set it to True instead of False, > but you may know that it triggers the error "fields.E332 Many-to-many > fields with intermediate tables must not be symmetrical.". > > I searched for a corresponding existing ticket a found this one which is > kind of related https://code.djangoproject.com/ticket/9475 > And you can see in the PR some discussion about the check > https://github.com/django/django/pull/8981#discussion_r247946460 > Thanks to the work of Collin Anderson in the previous PR I think we can > now remove that check. > > Questions I had: > > - retro compatibility? > > As the current behavior forces the user to set 'symmetrical=False', the > change is retro-compatible. > > - use 'through_defaults' when creating both objects or define a new > 'through_reverse_defaults' to give different values for each row? > > if you want symmetrical relationship, both objects should have the same > values > so I chose to use 'through_defaults' for both objects. Which was also what > was done in the #8981 > <https://github.com/django/django/pull/8981#discussion_r247946460> PR in > the first place. > > I have a patch > <https://github.com/django/django/compare/master...nadege:allow-m2m-intermediate-symmetrical> > > with theses changes: > > - removed the check > - removed tests for that check > - added tests (tests/m2m_through, tests/m2m_recursive) > - updated documentation (may need a bit more work) > - added back the use of 'through_defaults' of #8981 > <https://github.com/django/django/pull/8981#discussion_r247946460> in > the: > > if self.symmetrical: > self ._add_items(...) > > Tests suite runs fine. > > Any thoughts on this design change / new feature? > I'll be happy to create a ticket and submit my patch for reviews :) > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/4ef6730a-1f81-456c-9e05-7373da73da5e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.