summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2012-11-22 10:36:18 -0500
committerTim Graham <timograham@gmail.com>2012-11-22 10:36:18 -0500
commit71a3162a70a282f150f76e8f0fc5865aa7a338a4 (patch)
treea1ecec9431587ecdfdd888781b354438465a1fbe /docs/ref
parent9e11253497d7592964e311d007ac5ba28ca22808 (diff)
Documented behavior of get_or_create when multiple objects are returned.
Thanks Matt Lauber for the patch.
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/models/querysets.txt10
1 files changed, 6 insertions, 4 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index abf32c9621..40fa2d2b2f 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -1321,10 +1321,12 @@ The above example can be rewritten using ``get_or_create()`` like so::
Any keyword arguments passed to ``get_or_create()`` — *except* an optional one
called ``defaults`` — will be used in a :meth:`get()` call. If an object is
-found, ``get_or_create()`` returns a tuple of that object and ``False``. If an
-object is *not* found, ``get_or_create()`` will instantiate and save a new
-object, returning a tuple of the new object and ``True``. The new object will
-be created roughly according to this algorithm::
+found, ``get_or_create()`` returns a tuple of that object and ``False``. If
+multiple objects are found, ``get_or_create`` raises
+:exc:`~django.core.exceptions.MultipleObjectsReturned`. If an object is *not*
+found, ``get_or_create()`` will instantiate and save a new object, returning a
+tuple of the new object and ``True``. The new object will be created roughly
+according to this algorithm::
defaults = kwargs.pop('defaults', {})
params = dict([(k, v) for k, v in kwargs.items() if '__' not in k])