Skip to content

Commit 9521b69

Browse files
committed
#2054: Update exceptions to allow custom detail
This addresses the changes requested in #2054 and allows for custom messages that do not necessarily require a string formatter be present in the detail message.
1 parent 62ce653 commit 9521b69

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

rest_framework/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class MethodNotAllowed(APIException):
7070
default_detail = "Method '%s' not allowed."
7171

7272
def __init__(self, method, detail=None):
73-
self.detail = (detail or self.default_detail) % method
73+
self.detail = detail or (self.default_detail % method)
7474

7575

7676
class NotAcceptable(APIException):
@@ -87,7 +87,7 @@ class UnsupportedMediaType(APIException):
8787
default_detail = "Unsupported media type '%s' in request."
8888

8989
def __init__(self, media_type, detail=None):
90-
self.detail = (detail or self.default_detail) % media_type
90+
self.detail = detail or (self.default_detail % media_type)
9191

9292

9393
class Throttled(APIException):

0 commit comments

Comments
 (0)