Django raises some of its own exceptions as well as standard Python exceptions.
Kelas-kelas pengecualian inti django ditentukan dalam django.core.exceptions.
AppRegistryNotReady¶AppRegistryNotReady[sumber]¶This exception is raised when attempting to use models before the app loading process, which initializes the ORM, is complete.
ObjectDoesNotExist¶ObjectDoesNotExist[sumber]¶Kelas dasar untuk pengecualian DoesNotExist; ``try/except` untuk ObjectDoesNotExist akan menangkap pengecualian DoesNotExist untuk semua model.
Lihat get() untuk informasi lebih lanjut pada ObjectDoesNotExist dan DoesNotExist.
EmptyResultSet¶FieldDoesNotExist¶MultipleObjectsReturned¶MultipleObjectsReturned[sumber]¶The MultipleObjectsReturned exception is raised by a query if only
one object is expected, but multiple objects are returned. A base version
of this exception is provided in django.core.exceptions; each model
class contains a subclassed version that can be used to identify the
specific object type that has returned multiple objects.
Lihat get() untuk informasi lebih lanjut.
SuspiciousOperation¶SuspiciousOperation[sumber]¶The SuspiciousOperation exception is raised when a user has
performed an operation that should be considered suspicious from a security
perspective, such as tampering with a session cookie. Subclasses of
SuspiciousOperation include:
DisallowedHostDisallowedModelAdminLookupDisallowedModelAdminToFieldDisallowedRedirectInvalidSessionKeyRequestDataTooBigSuspiciousFileOperationSuspiciousMultipartFormSuspiciousSessionTooManyFieldsSentIf a SuspiciousOperation exception reaches the WSGI handler level it is
logged at the Error level and results in
a HttpResponseBadRequest. See the logging
documentation for more information.
PermissionDenied¶PermissionDenied[sumber]¶The PermissionDenied exception is raised when a user does not have
permission to perform the action requested.
ViewDoesNotExist¶ViewDoesNotExist[sumber]¶Pengecualian ViewDoesNotExist dimunculkan oleh django.urls ketika tampilan diminta tidak ada.
MiddlewareNotUsed¶MiddlewareNotUsed[sumber]¶The MiddlewareNotUsed exception is raised when a middleware is not
used in the server configuration.
ImproperlyConfigured¶ImproperlyConfigured[sumber]¶The ImproperlyConfigured exception is raised when Django is
somehow improperly configured -- for example, if a value in settings.py
is incorrect or unparseable.
FieldError¶FieldError[sumber]¶Pengecualian FieldError dimunculkan ketika ada masalah dengan bidang model. Ini terjadi untuk beberapa alasan:
ValidationError¶ValidationError[sumber]¶The ValidationError exception is raised when data fails form or
model field validation. For more information about validation, see
Form and Field Validation,
Model Field Validation and the
Validator Reference.
Pengecualian Penyelesai URL ditentukan dalam django.urls.
Resolver404¶Resolver404[sumber]¶Pengeculian Resolver404 dimunculkan dengan resolve() jika jalur dilewatkan ke resolve() tidak memetakan ke tampilan. Itu adalah sebuah subkelas dari django.http.Http404.
NoReverseMatch¶NoReverseMatch[sumber]¶Pengecualian NoReverseMatch dimunculkan dengan django.urls ketika URL cocok dalam URLconf anda tidak dapat dicirikan berdasarkan pada parameter disokong.
Pengecualian basisdata mungkin diimpor dari django.db.
Django membungkus pengecualian basisdata standar sehingga kode Django anda mempunyai jaminan penerapan umum pada kelas-kelas ini.
Pembungkus Django untuk pengecualian basisdata berperilaku tepatnya sama seperti pengecualian basisdata pokok. Lihat:pep:249, Spesifikasi API Basisdata Python v2.0, untuk informasi lebih jauh.
As per PEP 3134, a __cause__ attribute is set with the original
(underlying) database exception, allowing access to any additional
information provided.
models.ProtectedError¶Raised to prevent deletion of referenced objects when using
django.db.models.PROTECT. models.ProtectedError is a subclass
of IntegrityError.
Pengecualian Http mungkin diimpor dari django.http.
UnreadablePostError¶UnreadablePostError[sumber]¶UnreadablePostError dimunculkan ketika pengguna membatalkan unggahan.
Pengecualian transaksi ditentukan dalam django.db.transaction.
TransactionManagementError¶TransactionManagementError[sumber]¶TransactionManagementError is raised for any and all problems
related to database transactions.
Exceptions provided by the django.test package.
RedirectCycleError¶client.RedirectCycleError¶RedirectCycleError is raised when the test client detects a
loop or an overly long chain of redirects.
Django raises built-in Python exceptions when appropriate as well. See the Python documentation for further information on the Built-in Exceptions.
Mar 30, 2019