parts/django/docs/ref/exceptions.txt
changeset 307 c6bca38c1cbf
equal deleted inserted replaced
306:5ff1fc726848 307:c6bca38c1cbf
       
     1 =================
       
     2 Django Exceptions
       
     3 =================
       
     4 
       
     5 
       
     6 Django raises some Django specific exceptions as well as many standard
       
     7 Python exceptions.
       
     8 
       
     9 Django-specific Exceptions
       
    10 ==========================
       
    11 
       
    12 .. module:: django.core.exceptions
       
    13     :synopsis: Django specific exceptions
       
    14 
       
    15 ObjectDoesNotExist 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.QuerySet.get()` for further information
       
    29     on :exc:`ObjectDoesNotExist` and :exc:`DoesNotExist`.
       
    30 
       
    31 MultipleObjectsReturned
       
    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.QuerySet.get()` for further information.
       
    42 
       
    43 SuspiciousOperation
       
    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 
       
    51 PermissionDenied
       
    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 
       
    58 ViewDoesNotExist
       
    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 
       
    65 MiddlewareNotUsed
       
    66 -----------------
       
    67 .. exception:: MiddlewareNotUsed
       
    68 
       
    69     The :exc:`MiddlewareNotUsed` exception is raised when a middleware is not
       
    70     used in the server configuration.
       
    71 
       
    72 ImproperlyConfigured
       
    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 
       
    80 FieldError
       
    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 
       
    97 ValidationError
       
    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 Database Exceptions
       
   108 ===================
       
   109 
       
   110 Django wraps the standard database exceptions :exc:`DatabaseError` and
       
   111 :exc:`IntegrityError` so that your Django code has a guaranteed common
       
   112 implementation of these classes. These database exceptions are
       
   113 provided in :mod:`django.db`.
       
   114 
       
   115 The Django wrappers for database exceptions behave exactly the same as
       
   116 the underlying database exceptions. See `PEP 249 - Python Database API
       
   117 Specification v2.0`_ for further information.
       
   118 
       
   119 .. _`PEP 249 - Python Database API Specification v2.0`: http://www.python.org/dev/peps/pep-0249/
       
   120 
       
   121 Python Exceptions
       
   122 =================
       
   123 
       
   124 Django raises built-in Python exceptions when appropriate as well. See
       
   125 the Python `documentation`_ for further information on the built-in
       
   126 exceptions.
       
   127 
       
   128 .. _`documentation`: http://docs.python.org/lib/module-exceptions.html