Author: adrian
Date: 2011-08-25 21:34:40 -0700 (Thu, 25 Aug 2011)
New Revision: 16689
Modified:
django/trunk/docs/topics/db/queries.txt
Log:
Added a bit to 'Saving ManyToMany Fields' explicitly explaining how to add
multiple relations in one statement
Modified: django/trunk/docs/topics/db/queries.txt
===================================================================
--- django/trunk/docs/topics/db/queries.txt 2011-08-26 02:43:33 UTC (rev
16688)
+++ django/trunk/docs/topics/db/queries.txt 2011-08-26 04:34:40 UTC (rev
16689)
@@ -113,6 +113,15 @@
>>> joe = Author.objects.create(name="Joe")
>>> entry.authors.add(joe)
+To add multiple records to a ``ManyToManyField`` in one go, include multiple
+arguments in the call to ``add()``, like this::
+
+ >>> john = Author.objects.create(name="John")
+ >>> paul = Author.objects.create(name="Paul")
+ >>> george = Author.objects.create(name="George")
+ >>> ringo = Author.objects.create(name="Ringo")
+ >>> entry.authors.add(john, paul, george, ringo)
+
Django will complain if you try to assign or add an object of the wrong type.
Retrieving objects
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.