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.".
Thanks to the work of Collin Anderson in the previous PR I think we can now remove that check.
Questions I had:
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 PR in the first place.
I have
a patch 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 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 :)