mirror of https://github.com/django/django.git
[3.0.x] Refs #24763 -- Moved DoesNotExist to Model class docs.
Backport of b5f0efa19c
from master
This commit is contained in:
parent
dcb27ead84
commit
f026d761d6
|
@ -11,6 +11,20 @@ reference guides </ref/models/index>`.
|
|||
Attributes
|
||||
==========
|
||||
|
||||
``DoesNotExist``
|
||||
----------------
|
||||
|
||||
.. exception:: Model.DoesNotExist
|
||||
|
||||
This exception is raised by the ORM when an expected object is not found.
|
||||
For example, :meth:`.QuerySet.get` will raise it when no object is found
|
||||
for the given lookups.
|
||||
|
||||
Django provides a ``DoesNotExist`` exception as an attribute of each model
|
||||
class to identify the class of object that could not be found, allowing you
|
||||
to catch exceptions for a particular model class. The exception is a
|
||||
subclass of :exc:`django.core.exceptions.ObjectDoesNotExist`.
|
||||
|
||||
``objects``
|
||||
-----------
|
||||
|
||||
|
|
|
@ -841,20 +841,6 @@ duplicated. That also means you cannot use those methods on unsaved objects.
|
|||
Other attributes
|
||||
================
|
||||
|
||||
``DoesNotExist``
|
||||
----------------
|
||||
|
||||
.. exception:: Model.DoesNotExist
|
||||
|
||||
This exception is raised by the ORM in a couple places, for example by
|
||||
:meth:`QuerySet.get() <django.db.models.query.QuerySet.get>` when an object
|
||||
is not found for the given query parameters.
|
||||
|
||||
Django provides a ``DoesNotExist`` exception as an attribute of each model
|
||||
class to identify the class of object that could not be found and to allow
|
||||
you to catch a particular model class with ``try/except``. The exception is
|
||||
a subclass of :exc:`django.core.exceptions.ObjectDoesNotExist`.
|
||||
|
||||
``_state``
|
||||
----------
|
||||
|
||||
|
|
Loading…
Reference in New Issue