mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Clarified how to reference RelatedObjectDoesNotExist exceptions.
This commit is contained in:
parent
bc3b8f1524
commit
da02cbd1ef
@ -2012,13 +2012,14 @@ your resulting ``User`` model will have the following attributes::
|
||||
A ``RelatedObjectDoesNotExist`` exception is raised when accessing the reverse
|
||||
relationship if an entry in the related table doesn't exist. This is a subclass
|
||||
of the target model's :exc:`Model.DoesNotExist
|
||||
<django.db.models.Model.DoesNotExist>` exception. For example, if a user
|
||||
doesn't have a supervisor designated by ``MySpecialUser``::
|
||||
<django.db.models.Model.DoesNotExist>` exception and can be accessed as an
|
||||
attribute of the reverse accessor. For example, if a user doesn't have a
|
||||
supervisor designated by ``MySpecialUser``::
|
||||
|
||||
>>> user.supervisor_of
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
RelatedObjectDoesNotExist: User has no supervisor_of.
|
||||
try:
|
||||
user.supervisor_of
|
||||
except User.supervisor_of.RelatedObjectDoesNotExist:
|
||||
pass
|
||||
|
||||
.. _onetoone-arguments:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user