| | 1 | ================= |
| | 2 | Django Exceptions |
| | 3 | ================= |
| | 4 | |
| | 5 | This document describes the exceptions thrown by Django. |
| | 6 | |
| | 7 | Django uses many standard Python exceptions as well as some Django specific |
| | 8 | exceptions. |
| | 9 | |
| | 10 | Django Specific Exceptions |
| | 11 | ========================== |
| | 12 | |
| | 13 | Most of the Django specific exceptions are in the ``django.core.exceptions`` module. For example, ``django.core.exceptions.ViewDoesNotExist``. |
| | 14 | |
| | 15 | ObjectDoesNotExist and DoesNotExist |
| | 16 | ----------------------------------- |
| | 17 | The ``DoesNotExist`` exception is raised when an object is not for the given parameters of a query. The ``DoesNotExist`` exception is not in ``django.core.exceptions``. Instead, it is an attribute of the model class and inherits from ``ObjectDoesNotExist`` which is in ``django.core.exceptions``. See `get`_ for further information on ``ObjectDoesNotExist`` and ``DoesNotExist``. |
| | 18 | |
| | 19 | .. _`get`: ../db-api/#get-kwargs |
| | 20 | |
| | 21 | MultipleObjectsReturned |
| | 22 | ----------------------- |
| | 23 | The ``MultipleObjectsReturned`` exception is raised by a query if only one object is expected, but multiple objects are returned. See `get`_ for further information. The ``MultipleObjectsReturned`` exception is an attribute of a model class and it is in ``django.core.exceptions``. |
| | 24 | |
| | 25 | .. _`get`: ../db-api/#get-kwargs |
| | 26 | |
| | 27 | SuspiciousOperation |
| | 28 | ------------------- |
| | 29 | |
| | 30 | PermissionDenied |
| | 31 | ---------------- |
| | 32 | |
| | 33 | ViewDoesNotExist |
| | 34 | ---------------- |
| | 35 | |
| | 36 | MiddlewareNotUsed |
| | 37 | ----------------- |
| | 38 | |
| | 39 | ImproperlyConfigured |
| | 40 | -------------------- |
| | 41 | |
| | 42 | FieldError |
| | 43 | ---------- |