From f27795692416927e4c2b1788e63ebc2c7a809b85 Mon Sep 17 00:00:00 2001 From: mojtaba <121169359+mojtabapaso@users.noreply.github.com> Date: Thu, 31 Aug 2023 13:21:20 +0330 Subject: [PATCH] Update exceptions.py I added a new exception class called Conflict to the Django REST framework. This exception is raised when a user's request conflicts with existing data in the system. --- rest_framework/exceptions.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rest_framework/exceptions.py b/rest_framework/exceptions.py index bc20fcaa3..037d071fd 100644 --- a/rest_framework/exceptions.py +++ b/rest_framework/exceptions.py @@ -203,7 +203,11 @@ class NotFound(APIException): default_detail = _('Not found.') default_code = 'not_found' - +class Conflict(APIException): + status_code = status.HTTP_409_CONFLICT + default_detail = _('Conflict request.') + default_code = 'conflict_error' + class MethodNotAllowed(APIException): status_code = status.HTTP_405_METHOD_NOT_ALLOWED default_detail = _('Method "{method}" not allowed.')