Navigation Menu

Skip to content

Commit

Permalink
Fixed #7260 -- Corrected the description of the exception returned by…
Browse files Browse the repository at this point in the history
… get() when multiple objects match the search criteria. Thanks, leotr.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7559 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
freakboy3742 committed May 29, 2008
1 parent 8a0b8d9 commit 6b39dd6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docs/db-api.txt
Expand Up @@ -1061,7 +1061,12 @@ they query the database each time they're called.
Returns the object matching the given lookup parameters, which should be in Returns the object matching the given lookup parameters, which should be in
the format described in `Field lookups`_. the format described in `Field lookups`_.


``get()`` raises ``AssertionError`` if more than one object was found. ``get()`` raises ``MultipleObjectsReturned`` if more than one object was found.
The ``MultipleObjectsReturned`` exception is an attribute of the model class.
For example, the following will raise ``MultipleObjectsReturned`` if there
are more than one authors with the name of 'John'::

Author.objects.get(name='John') # raises Author.MultipleObjectsReturned


``get()`` raises a ``DoesNotExist`` exception if an object wasn't found for the ``get()`` raises a ``DoesNotExist`` exception if an object wasn't found for the
given parameters. The ``DoesNotExist`` exception is an attribute of the model given parameters. The ``DoesNotExist`` exception is an attribute of the model
Expand Down

0 comments on commit 6b39dd6

Please sign in to comment.