aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/exceptions.py
diff options
context:
space:
mode:
authorTom Christie2012-08-26 22:13:26 +0100
committerTom Christie2012-08-26 22:13:26 +0100
commit474780f9d6cdb593f82130d39b6a6ff7ef8b78e0 (patch)
treea945404f8ff218ef882505b5460b8a01b01bfc8c /djangorestframework/exceptions.py
parent3928802178c8361d6d24364a5d0b866d6907c084 (diff)
downloaddjango-rest-framework-474780f9d6cdb593f82130d39b6a6ff7ef8b78e0.tar.bz2
Remove 405 method not allowed ImmediateResponse
Diffstat (limited to 'djangorestframework/exceptions.py')
-rw-r--r--djangorestframework/exceptions.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/djangorestframework/exceptions.py b/djangorestframework/exceptions.py
index b29d96ba..3f7e9029 100644
--- a/djangorestframework/exceptions.py
+++ b/djangorestframework/exceptions.py
@@ -17,12 +17,20 @@ class PermissionDenied(Exception):
self.detail = detail or self.default_detail
+class MethodNotAllowed(Exception):
+ status_code = status.HTTP_405_METHOD_NOT_ALLOWED
+ default_detail = "Method '%s' not allowed"
+
+ def __init__(self, method, detail):
+ self.detail = (detail or self.default_detail) % method
+
+
class UnsupportedMediaType(Exception):
- status_code = 415
- default_detail = 'Unsupported media type in request'
+ status_code = status.HTTP_415_UNSUPPORTED_MEDIA_TYPE
+ default_detail = "Unsupported media type '%s' in request"
- def __init__(self, detail=None):
- self.detail = detail or self.default_detail
+ def __init__(self, media_type, detail=None):
+ self.detail = (detail or self.default_detail) % media_type
# class Throttled(Exception):
# def __init__(self, detail):