532 | | disabled for similar reasons. However, the |
533 | | :meth:`~django.db.models.fields.related.RelatedManager.clear` method can be |
534 | | used to remove all many-to-many relationships for an instance:: |
| 532 | disabled for similar reasons. If the custom through-table defined by the |
| 533 | intermediate model does not enforce uniqueness on the ``(model1, model2)`` pair, |
| 534 | a ``remove`` call will not provide enough information as to which intermediate |
| 535 | model instance should be deleted:: |
| 536 | |
| 537 | >>> m3 = Membership(person=ringo, group=beatles, |
| 538 | ... date_joined=date(1968, 9, 4), |
| 539 | ... invite_reason="You've been gone for a month and we miss you") |
| 540 | >>> beatles.members.all() |
| 541 | <QuerySet [<Person: Ringo Starr>, <Person: Paul McCartney>, |
| 542 | <Person: Ringo Starr>]> |
| 543 | # THIS WILL NOT WORK BECAUSE IT CANNOT TELL WHICH MEMBERSHIP TO REMOVE |
| 544 | >>> beatles.members.remove(ringo) |
| 545 | |
| 546 | However, the :meth:`~django.db.models.fields.related.RelatedManager.clear` |
| 547 | method can be used to remove all many-to-many relationships for an instance:: |