An exception is a rare occurrence that causes a program to fail. Django has its own exception classes to cope with this circumstance, and it also supports all fundamental Python exceptions. some of the exception classes are listed below:
- MultipleObjectsReturned – If just one item is anticipated but many objects are returned, this error is thrown by the query.
- ViewDoesNotExist – When a requested view does not exist, Django.URLs raise this exception.
- PermissionDenied – It’s triggered when a user doesn’t have the necessary permissions to perform the requested activity.
- SuspiciousOperation – The query throws this error if only one item is expected but several things are returned.
- ValidationError – It’s triggered when data validation fails on a form or a model field.
- FieldDoesNotExist – It raises when the requested field does not exist.
- ObjectDoesNotExist – The base class for DoesNotExist exceptions.
- AppRegistryNotReady – It is raised when attempting to use models before the app loading process.
- EmptyResultSet – If a query does not return any result, this exception is raised.
Leave a Reply