Thursday, June 25, 2020

Re: Symmetrical, Self-referencing ManyToManyField with Through Table

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, and then your get_connections() method works as expected! It seems like using a custom through table is causing this somehow. I haven't found a fix but will keep looking.

 Dan, thanks for looking into this issue.

I found the unit tests for this capability in https://github.com/django/django/tree/master/tests/m2m_through which seems to indicate that it does work.

I updated my version of Django to 3.1.b1 and copied the models and tests into my code. Neither the admin nor queries on the ManyToManyField return the full "symmetric" results.

Any other ideas?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/05819cd1-7c67-4c64-bfce-69934315782eo%40googlegroups.com.

No comments:

Post a Comment