Ticket #6842: r8643.diff

File r8643.diff, 3.4 KB (added by John Shimek, 16 years ago)
  • docs/exceptions.txt

     
     1=================
     2Django Exceptions
     3=================
     4
     5This document describes the exceptions raised by Django.
     6
     7Django raises some Django specific exceptions as well as many standard Python exceptions.
     8
     9Django Specific Exceptions
     10==========================
     11
     12Most of the Django specific exceptions are in the ``django.core.exceptions`` module.  For example,
     13``django.core.exceptions.ViewDoesNotExist``.
     14
     15ObjectDoesNotExist and DoesNotExist
     16-----------------------------------
     17The ``DoesNotExist`` exception is raised when an object is not found for the given parameters of a
     18query.  The ``DoesNotExist`` exception is not in ``django.core.exceptions``.  Instead, it is an
     19attribute of the model class and inherits from ``ObjectDoesNotExist`` which is in
     20``django.core.exceptions``.  See `get`_ for further information on ``ObjectDoesNotExist`` and
     21``DoesNotExist``.
     22
     23.. _`get`: ../db-api/#get-kwargs
     24
     25MultipleObjectsReturned
     26-----------------------
     27The ``MultipleObjectsReturned`` exception is raised by a query if only one object is expected, but
     28multiple objects are returned.  See `get`_ for further information.  The ``MultipleObjectsReturned``
     29exception is an attribute of a model class and it is in ``django.core.exceptions``.
     30
     31.. _`get`: ../db-api/#get-kwargs
     32
     33SuspiciousOperation
     34-------------------
     35The ``SuspiciousOperation`` exception is raised when a user did something suspicious.
     36
     37PermissionDenied
     38----------------
     39The ``PermissionDenied`` exception is raised when a user does not have permission to perform the action
     40attempted.
     41
     42ViewDoesNotExist
     43----------------
     44The ``ViewDoesNotExist`` exception is raised by ``django.core.urlresolvers`` when a requested view does
     45not exist.
     46
     47MiddlewareNotUsed
     48-----------------
     49The ``MiddlewareNotUsed`` exception is raised when a middleware is not used in the server configuration.
     50
     51ImproperlyConfigured
     52--------------------
     53The ``ImproperlyConfigured`` exception is raised when Django is somehow improperly configured.
     54
     55FieldError
     56----------
     57The ``FieldError`` exception is raised when there is a problem with a model field.  This can happen for
     58several reasons, some of which are:
     59   
     60    - A field in a model clashes with a field of the same name from an abstract base class
     61    - An infinite loop is caused by ordering
     62    - A keyword cannot be parsed from the filter parameters
     63    - If a field cannot be determined from a keyword in the query parameters
     64    - If a join is not permitted on the specified field
     65    - If a field name is invalid
     66    - If a query contains invalid order_by arguments
     67
     68Database Exceptions
     69===================
     70Django raises or propagates standard database exceptions, such as DatabaseError and IntegrityError,
     71when appropriate for operations on model objects.  See
     72`PEP 249 - Python Database API Specification v2.0`_ for further information about database exceptions.
     73
     74.. _`PEP 249 - Python Database API Specification v2.0`: http://www.python.org/dev/peps/pep-0249/
     75
     76Python Exceptions
     77=================
     78Django raises built-in Python exceptions when appropriate as well. See the Python `documentation`_ for
     79further information on the built-in exceptions.
     80
     81.. _`documentation`: http://docs.python.org/lib/module-exceptions.html
     82
Back to Top