aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/exceptions.py
diff options
context:
space:
mode:
authorTom Christie2012-09-14 22:42:29 +0100
committerTom Christie2012-09-14 22:42:29 +0100
commitb3e29d9576f1b1b6d12f9abfeb4a06f669b45202 (patch)
treed89770f15bdfa6b00e4a91e2a8d0a270106065b8 /djangorestframework/exceptions.py
parentb7b8cd11b1aad3fcf4bad221d164bb55e0bf5859 (diff)
downloaddjango-rest-framework-b3e29d9576f1b1b6d12f9abfeb4a06f669b45202.tar.bz2
Moved content negotiation out of response. Nicer exception handling now.
Diffstat (limited to 'djangorestframework/exceptions.py')
-rw-r--r--djangorestframework/exceptions.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/djangorestframework/exceptions.py b/djangorestframework/exceptions.py
index 3f5b23f6..6930515d 100644
--- a/djangorestframework/exceptions.py
+++ b/djangorestframework/exceptions.py
@@ -39,6 +39,15 @@ class MethodNotAllowed(APIException):
self.detail = (detail or self.default_detail) % method
+class NotAcceptable(APIException):
+ status_code = status.HTTP_406_NOT_ACCEPTABLE
+ default_detail = "Could not satisfy the request's Accept header"
+
+ def __init__(self, detail=None, available_renderers=None):
+ self.detail = detail or self.default_detail
+ self.available_renderers = available_renderers
+
+
class UnsupportedMediaType(APIException):
status_code = status.HTTP_415_UNSUPPORTED_MEDIA_TYPE
default_detail = "Unsupported media type '%s' in request."