Django の例外Link to this heading
Django は普通の Python の例外の他に、いくつか独自の例外も起こします。
Django Core 例外Link to this heading
Django core 例外クラスは django.core.exceptions で定義されています。
AppRegistryNotReadyLink to this heading
- exception AppRegistryNotReadyLink to this definition
This exception is raised when attempting to use models before the app loading process, which initializes the ORM, is complete.
ObjectDoesNotExistLink to this heading
- exception ObjectDoesNotExistLink to this definition
The base class for
DoesNotExistexceptions; atry/exceptforObjectDoesNotExistwill catchDoesNotExistexceptions for all models.See
get()for further information onObjectDoesNotExistandDoesNotExist.
EmptyResultSetLink to this heading
- exception EmptyResultSetLink to this definition
EmptyResultSetmay be raised during query generation if a query won't return any results. Most Django projects won't encounter this exception, but it might be useful for implementing custom lookups and expressions.
FieldDoesNotExistLink to this heading
- exception FieldDoesNotExistLink to this definition
The
FieldDoesNotExistexception is raised by a model's_meta.get_field()method when the requested field does not exist on the model or on the model's parents.
MultipleObjectsReturnedLink to this heading
- exception MultipleObjectsReturnedLink to this definition
The
MultipleObjectsReturnedexception is raised by a query if only one object is expected, but multiple objects are returned. A base version of this exception is provided indjango.core.exceptions; each model class contains a subclassed version that can be used to identify the specific object type that has returned multiple objects.詳しくは
get()を見てください。
SuspiciousOperationLink to this heading
- exception SuspiciousOperationLink to this definition
The
SuspiciousOperationexception 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 ofSuspiciousOperationinclude:DisallowedHostDisallowedModelAdminLookupDisallowedModelAdminToFieldDisallowedRedirectInvalidSessionKeyRequestDataTooBigSuspiciousFileOperationSuspiciousMultipartFormSuspiciousSessionTooManyFieldsSent
SuspiciousOperation例外が WSGI ハンドラーのレベルに到達すると、Errorレベルがログに記録され、HttpResponseBadRequestが返されます。詳しくは logging documentation を参照してください。
PermissionDeniedLink to this heading
- exception PermissionDeniedLink to this definition
PermissionDenied例外は、ユーザーにリクエストされたアクションを実行する権限がない場合に発生します。
ViewDoesNotExistLink to this heading
- exception ViewDoesNotExistLink to this definition
ViewDoesNotExist例外は、リクエストされたビューが存在しないい場合に、django.urlsによって発生します。
MiddlewareNotUsedLink to this heading
- exception MiddlewareNotUsedLink to this definition
MiddlewareNotUsed例外は、サーバーの設定の中でミドルウェアが使用されなかった時に発生します。
ImproperlyConfiguredLink to this heading
- exception ImproperlyConfiguredLink to this definition
ImproperlyConfigured例外は、Django が何らかの点で不適切に設定されている場合に発生します。たとえば、settings.pyに含まれる値が不正であったり、パースできないような場合が考えられます。
FieldErrorLink to this heading
- exception FieldErrorLink to this definition
FieldError例外は、モデルのフィールドに問題がある時に発生します。発生理由としては、次のようないくつかの理由が考えられます。A field in a model clashes with a field of the same name from an abstract base class
An infinite loop is caused by ordering
A keyword cannot be parsed from the filter parameters
A field cannot be determined from a keyword in the query parameters
A join is not permitted on the specified field
A field name is invalid
A query contains invalid order_by arguments
ValidationErrorLink to this heading
- exception ValidationErrorLink to this definition
ValidationError例外は、データがフォームまたはモデルのフィールド検証に失敗すると発生します。検証 (validation) のより詳しい情報については、Form and Field Validation や Model Field Validation、Validator Reference を参照してください。
NON_FIELD_ERRORSLink to this heading
- NON_FIELD_ERRORSLink to this definition
ValidationErrors that don't belong to a particular field in a form
or model are classified as NON_FIELD_ERRORS. This constant is used
as a key in dictionaries that otherwise map fields to their respective
list of errors.
URL Resolver の例外Link to this heading
URL Resolver の例外は django.urls で定義されています。
Resolver404Link to this heading
- exception Resolver404Link to this definition
The
Resolver404exception is raised byresolve()if the path passed toresolve()doesn't map to a view. It's a subclass ofdjango.http.Http404.
NoReverseMatchLink to this heading
- exception NoReverseMatchLink to this definition
The
NoReverseMatchexception is raised bydjango.urlswhen a matching URL in your URLconf cannot be identified based on the parameters supplied.
データベースの例外Link to this heading
データベースの例外は django.db からインポートできます。
Django wraps the standard database exceptions so that your Django code has a guaranteed common implementation of these classes.
- exception ErrorLink to this definition
- exception InterfaceErrorLink to this definition
- exception DatabaseErrorLink to this definition
- exception DataErrorLink to this definition
- exception OperationalErrorLink to this definition
- exception IntegrityErrorLink to this definition
- exception InternalErrorLink to this definition
- exception ProgrammingErrorLink to this definition
- exception NotSupportedErrorLink to this definition
The Django wrappers for database exceptions behave exactly the same as the underlying database exceptions. See PEP 249, the Python Database API Specification v2.0, for further information.
As per PEP 3134, a __cause__ attribute is set with the original
(underlying) database exception, allowing access to any additional
information provided.
- exception models.ProtectedErrorLink to this definition
Raised to prevent deletion of referenced objects when using
django.db.models.PROTECT. models.ProtectedError is a subclass
of IntegrityError.
Http の例外Link to this heading
Http の例外は django.http からインポートすることができます。
UnreadablePostErrorLink to this heading
- exception UnreadablePostErrorLink to this definition
UnreadablePostErrorは、ユーザーがアップロードをキャンセルすると発生します。
トランザクションの例外Link to this heading
トランザクションの例外は django.db.transaction で定義されています。
TransactionManagementErrorLink to this heading
- exception TransactionManagementErrorLink to this definition
TransactionManagementErrorが発生するのは、データベースのトランザクションに関するあらゆる問題に対してです。
テストフレームワークの例外Link to this heading
django.test パッケージが提供する例外です。
RedirectCycleErrorLink to this heading
- exception client.RedirectCycleErrorLink to this definition
RedirectCycleErrorは、テストクライアントがループまたは過度に長いリダイレクトチェーンを検出した時に発生します。
Python の例外Link to this heading
Django は、十分適切な場合にはビルトインの Python の例外を起こします。詳しい情報については、Python のドキュメント Built-in Exceptions を読んでください。