mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-25 19:14:01 +03:00
#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.
This commit is contained in:
parent
62ce653c61
commit
9521b69711
|
@ -70,7 +70,7 @@ class MethodNotAllowed(APIException):
|
|||
default_detail = "Method '%s' not allowed."
|
||||
|
||||
def __init__(self, method, detail=None):
|
||||
self.detail = (detail or self.default_detail) % method
|
||||
self.detail = detail or (self.default_detail % method)
|
||||
|
||||
|
||||
class NotAcceptable(APIException):
|
||||
|
@ -87,7 +87,7 @@ class UnsupportedMediaType(APIException):
|
|||
default_detail = "Unsupported media type '%s' in request."
|
||||
|
||||
def __init__(self, media_type, detail=None):
|
||||
self.detail = (detail or self.default_detail) % media_type
|
||||
self.detail = detail or (self.default_detail % media_type)
|
||||
|
||||
|
||||
class Throttled(APIException):
|
||||
|
|
Loading…
Reference in New Issue
Block a user