Hello Nadège,

While I'm not an expert of this area, your proposal makes sense to me. It looks 
like a reasonable extension of previous work. You can go ahead with a ticket 
and a pull request.

Best regards,

-- 
Aymeric.



> On 23 Apr 2019, at 12:09, Nadège Michel <michel.nad...@gmail.com> 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 
> <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 
> <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 
> <mailto:django-developers+unsubscr...@googlegroups.com>.
> To post to this group, send email to django-developers@googlegroups.com 
> <mailto:django-developers@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-developers 
> <https://groups.google.com/group/django-developers>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-developers/3e2f799d-3444-407b-bc81-523c3f55ec0b%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-developers/3e2f799d-3444-407b-bc81-523c3f55ec0b%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
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/8B0DF00A-8241-4454-80C9-D1F6B91DAA14%40polytechnique.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to