M2M relationship not behaving as I would expect

2019-07-21 Thread Don Baldwin
Hi, I have a many-to-many relationship between users and things, where a user can select multiple things, and a thing can be selected by multiple users. The relationship between users and things also contains data, so I've specifically setup a through table. When I add a user to a thing, I guess

Re: M2M relationship not behaving as I would expect

2019-07-21 Thread Mike Dewhirst
You can constrain uniqueness in the through table and/or the other tables to represent whatever real-world constraints you need. Otherwise you can have as many duplicated relationships as you want. Each through record has its own id so the database is happy no matter how many go in. Connected

Re: M2M relationship not behaving as I would expect

2019-07-23 Thread Don Baldwin
FYI, I was able to get this working with a small change to the query, from: data = list(TestThing.objects.all().values('user__user_data', 'thing_data', 'user__testbridge__bridge_data')) to: data = list(Test