Changes between Version 2 and Version 3 of Ticket #34207, comment 3


Ignore:
Timestamp:
Dec 10, 2022, 12:21:14 PM (2 years ago)
Author:
Simon Charette

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #34207, comment 3

    v2 v3  
    77In the example you've just provided you don't use `members.add` to add the second relationship to Ringo but rely on explicit `Membership` creation which is supported.
    88
    9 To make it clear, intermediary models that don't define a strict unique relationship on `(from, to)` are supported. However `add(through_defaults)` is focused on enforcing that at least one entry of the `(from, to)` tuple exists and doesn't make any assumption with regards to the unique constraints defined on the intermediary model.
     9To make it clear, intermediary models that don't define a strict unique relationship on `(from, to)` are supported. However `add` is focused on enforcing that at least one entry of the `(from, to)` tuple exists and allows for insertion defaults to be provided if the relationship is missing via `through_defaults`. It doesn't make any assumption with regards to the unique constraints defined on the intermediary model.
    1010
    1111If you want to enforce the unique existence of a tuple that is a superset of the the `(from, to)` relationship you should use `get_or_create` instead of expecting `add` to figure out which of your unique constraints should be enforced based on your provided `through_defaults` (as there could be many).
Back to Top