Changes between Initial Version and Version 1 of Ticket #34207, comment 3


Ignore:
Timestamp:
Dec 10, 2022, 12:19:25 PM (22 months ago)
Author:
Simon Charette

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #34207, comment 3

    initial v1  
    33Could you elaborate on that? From what I can read none of the examples you linked suggest that `add` supports this feature?
    44
    5 There is effectively a section that points at the fact that `remove(related)` will remove all entries matching the `(from, to)` tuple but defined by the many-to-many
     5There is effectively a section that points at the fact that `remove(related)` will remove all entries matching the `(from, to)` tuple but defined by the many-to-many but I don't see how that demonstrates that your reported use case should be supported.
    66
    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.
     
    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(through_defaults)` to figure out which of your unique constraints should be enforced based on your provided `through_defaults`.
     12
     13
     14{{{#!python
     15StatementLocation.objects.get_or_create(
     16    section=sect,
     17    statement=statement,
     18    sl_version=new_version,
     19)
     20}}}
Back to Top