Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Added a bit to 'Saving ManyToMany Fields' explicitly explaining how t…

…o add multiple relations in one statement

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 804a6db86e8b1c129429291da4aebbd797c77ddb 1 parent 5eeb2d5
@adrianholovaty adrianholovaty authored
Showing with 9 additions and 0 deletions.
  1. +9 −0 docs/topics/db/queries.txt
9 docs/topics/db/queries.txt
@@ -113,6 +113,15 @@ method on the field to add a record to the relation. This example adds the
>>> 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

0 comments on commit 804a6db

Please sign in to comment.
Something went wrong with that request. Please try again.