Re: Symmetrical, Self-referencing ManyToManyField with Through Table

2020-06-25 Thread Jim Shepherd
Nice solution. Thanks! On Thursday, June 25, 2020 at 5:49:23 PM UTC-4, Dan Madere wrote: > > I don't know of a way to configure the admin do that, but one solution > would be to use signals to notice when one-way records are created, then > automatically create the record for reverse

Re: Symmetrical, Self-referencing ManyToManyField with Through Table

2020-06-25 Thread Dan Madere
I don't know of a way to configure the admin do that, but one solution would be to use signals to notice when one-way records are created, then automatically create the record for reverse relationship. We need to notice when records are deleted as well. This approach would allow showing one

Re: Symmetrical, Self-referencing ManyToManyField with Through Table

2020-06-25 Thread Jim Shepherd
After reviewing the tests, I think I now understand what is going on. Basically, for symmetric ManyToManyField, Django creates entries for both directions automatically if the correct interface is used. From the test models: class PersonSelfRefM2M(models.Model): name =

Re: Symmetrical, Self-referencing ManyToManyField with Through Table

2020-06-25 Thread Jim Shepherd
On Thursday, June 25, 2020 at 10:26:25 AM UTC-4, Dan Madere wrote: > > I tried out the example code, and can replicate this. What's interesting > is that if I try removing the ContactConnection model, and the "through" > attribute, this allows Django to create the intermediate table on its own,

Re: Symmetrical, Self-referencing ManyToManyField with Through Table

2020-06-25 Thread Dan Madere
I tried out the example code, and can replicate this. What's interesting is that if I try removing the ContactConnection model, and the "through" attribute, this allows Django to create the intermediate table on its own, and then your get_connections() method works as expected! It seems like

Re: Symmetrical, Self-referencing ManyToManyField with Through Table

2020-06-25 Thread Jim Shepherd
Mike, Thanks for your suggestions. Just a stab in the dark - have you tried giving from_contact a > related_name? > Yes, I have tried a few different combinations of providing a single related_name and various naming conventions when providing related_name on both ForeignKey fields without

Re: Symmetrical, Self-referencing ManyToManyField with Through Table

2020-06-24 Thread Mike Dewhirst
On 25/06/2020 8:29 am, Jim Shepherd wrote: I am unable to get a symmetrical, self-referencing ManyToManyField with a through table to actually be symmetrical, at least through the Admin interface. I am using Django 3.0 so it looks like the capability is supported. Models: class