summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCody Scott <cody.j.b.scott@gmail.com>2013-11-03 11:55:11 -0500
committerTim Graham <timograham@gmail.com>2013-11-08 19:25:21 -0500
commit82e756da83085b2fc5710b11d6d2718cda85a546 (patch)
tree4e0f0d58eec3ea86cf7ea6f03ec3ded76a1afdb8
parentc9917f4c83982bd14553f2a953d7ea9e9dc150fd (diff)
[1.6.x] Noted that .clear() will delete intermediary models
Backport of a8e84521c4 from master
-rw-r--r--docs/topics/db/models.txt9
1 files changed, 6 insertions, 3 deletions
diff --git a/docs/topics/db/models.txt b/docs/topics/db/models.txt
index 2d61bf44a6..81c07b8d15 100644
--- a/docs/topics/db/models.txt
+++ b/docs/topics/db/models.txt
@@ -469,7 +469,7 @@ the intermediate model::
>>> beatles = Group.objects.create(name="The Beatles")
>>> m1 = Membership(person=ringo, group=beatles,
... date_joined=date(1962, 8, 16),
- ... invite_reason= "Needed a new drummer.")
+ ... invite_reason="Needed a new drummer.")
>>> m1.save()
>>> beatles.members.all()
[<Person: Ringo Starr>]
@@ -477,7 +477,7 @@ the intermediate model::
[<Group: The Beatles>]
>>> m2 = Membership.objects.create(person=paul, group=beatles,
... date_joined=date(1960, 8, 1),
- ... invite_reason= "Wanted to form a band.")
+ ... invite_reason="Wanted to form a band.")
>>> beatles.members.all()
[<Person: Ringo Starr>, <Person: Paul McCartney>]
@@ -504,8 +504,11 @@ disabled for similar reasons. However, the
:meth:`~django.db.models.fields.related.RelatedManager.clear` method can be
used to remove all many-to-many relationships for an instance::
- # Beatles have broken up
+ >>> # Beatles have broken up
>>> beatles.members.clear()
+ >>> # Note that this deletes the intermediate model instances
+ >>> Membership.objects.all()
+ []
Once you have established the many-to-many relationships by creating instances
of your intermediate model, you can issue queries. Just as with normal