/docs/ref/exceptions.txt
Plain Text | 154 lines | 112 code | 42 blank | 0 comment | 0 complexity | 1bc2f1f4d395944fd6b969c9f66a5a08 MD5 | raw file
Possible License(s): BSD-3-Clause
1================= 2Django Exceptions 3================= 4 5 6Django raises some Django specific exceptions as well as many standard 7Python exceptions. 8 9Django-specific Exceptions 10========================== 11 12.. module:: django.core.exceptions 13 :synopsis: Django specific exceptions 14 15ObjectDoesNotExist and DoesNotExist 16----------------------------------- 17.. exception:: DoesNotExist 18.. exception:: ObjectDoesNotExist 19 20 The :exc:`DoesNotExist` exception is raised when an object is not found 21 for the given parameters of a query. 22 23 :exc:`ObjectDoesNotExist` is defined in :mod:`django.core.exceptions`. 24 :exc:`DoesNotExist` is a subclass of the base :exc:`ObjectDoesNotExist` 25 exception that is provided on every model class as a way of 26 identifying the specific type of object that could not be found. 27 28 See :meth:`~django.db.models.query.QuerySet.get()` for further information 29 on :exc:`ObjectDoesNotExist` and :exc:`DoesNotExist`. 30 31MultipleObjectsReturned 32----------------------- 33.. exception:: MultipleObjectsReturned 34 35 The :exc:`MultipleObjectsReturned` exception is raised by a query if only 36 one object is expected, but multiple objects are returned. A base version 37 of this exception is provided in :mod:`django.core.exceptions`; each model 38 class contains a subclassed version that can be used to identify the 39 specific object type that has returned multiple objects. 40 41 See :meth:`~django.db.models.query.QuerySet.get()` for further information. 42 43SuspiciousOperation 44------------------- 45.. exception:: SuspiciousOperation 46 47 The :exc:`SuspiciousOperation` exception is raised when a user has performed 48 an operation that should be considered suspicious from a security perspective, 49 such as tampering with a session cookie. 50 51PermissionDenied 52---------------- 53.. exception:: PermissionDenied 54 55 The :exc:`PermissionDenied` exception is raised when a user does not have 56 permission to perform the action requested. 57 58ViewDoesNotExist 59---------------- 60.. exception:: ViewDoesNotExist 61 62 The :exc:`ViewDoesNotExist` exception is raised by 63 :mod:`django.core.urlresolvers` when a requested view does not exist. 64 65MiddlewareNotUsed 66----------------- 67.. exception:: MiddlewareNotUsed 68 69 The :exc:`MiddlewareNotUsed` exception is raised when a middleware is not 70 used in the server configuration. 71 72ImproperlyConfigured 73-------------------- 74.. exception:: ImproperlyConfigured 75 76 The :exc:`ImproperlyConfigured` exception is raised when Django is 77 somehow improperly configured -- for example, if a value in ``settings.py`` 78 is incorrect or unparseable. 79 80FieldError 81---------- 82.. exception:: FieldError 83 84 The :exc:`FieldError` exception is raised when there is a problem with a 85 model field. This can happen for several reasons: 86 87 - A field in a model clashes with a field of the same name from an 88 abstract base class 89 - An infinite loop is caused by ordering 90 - A keyword cannot be parsed from the filter parameters 91 - A field cannot be determined from a keyword in the query 92 parameters 93 - A join is not permitted on the specified field 94 - A field name is invalid 95 - A query contains invalid order_by arguments 96 97ValidationError 98--------------- 99.. exception:: ValidationError 100 101 The :exc:`ValidationError` exception is raised when data fails form or 102 model field validation. For more information about validation, see 103 :doc:`Form and Field Validation </ref/forms/validation>`, 104 :ref:`Model Field Validation <validating-objects>` and the 105 :doc:`Validator Reference </ref/validators>`. 106 107.. currentmodule:: django.core.urlresolvers 108 109NoReverseMatch 110-------------- 111.. exception:: NoReverseMatch 112 113 The :exc:`NoReverseMatch` exception is raised by 114 :mod:`django.core.urlresolvers` when a matching URL in your URLconf 115 cannot be identified based on the parameters supplied. 116 117.. currentmodule:: django.db 118 119Database Exceptions 120=================== 121 122Django wraps the standard database exceptions :exc:`DatabaseError` and 123:exc:`IntegrityError` so that your Django code has a guaranteed common 124implementation of these classes. These database exceptions are 125provided in :mod:`django.db`. 126 127.. exception:: DatabaseError 128.. exception:: IntegrityError 129 130The Django wrappers for database exceptions behave exactly the same as 131the underlying database exceptions. See `PEP 249 - Python Database API 132Specification v2.0`_ for further information. 133 134.. _`PEP 249 - Python Database API Specification v2.0`: http://www.python.org/dev/peps/pep-0249/ 135 136.. currentmodule:: django.db.transaction 137 138Transaction Exceptions 139====================== 140 141.. exception:: TransactionManagementError 142 143 The :exc:`TransactionManagementError` is raised for any and all problems 144 related to database transactions. It is available from 145 :mod:`django.db.transaction`. 146 147Python Exceptions 148================= 149 150Django raises built-in Python exceptions when appropriate as well. See 151the Python `documentation`_ for further information on the built-in 152exceptions. 153 154.. _`documentation`: http://docs.python.org/lib/module-exceptions.html