aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/exceptions.py
diff options
context:
space:
mode:
authorTom Christie2014-10-17 13:23:14 +0100
committerTom Christie2014-10-17 13:23:14 +0100
commit05cbec9dd7f9f0b6a9b59b29ac6c9272b6ae50d8 (patch)
treede0da30019c3f0d3ac34bfa3317767fc6e6ad36f /rest_framework/exceptions.py
parent5882a7a9d52de1084d2be68adc73dc19bc706e4a (diff)
downloaddjango-rest-framework-05cbec9dd7f9f0b6a9b59b29ac6c9272b6ae50d8.tar.bz2
Use serializers.ValidationError
Diffstat (limited to 'rest_framework/exceptions.py')
-rw-r--r--rest_framework/exceptions.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/rest_framework/exceptions.py b/rest_framework/exceptions.py
index b7c2d16d..388d3dee 100644
--- a/rest_framework/exceptions.py
+++ b/rest_framework/exceptions.py
@@ -24,7 +24,14 @@ class APIException(Exception):
return self.detail
-class ValidationFailed(APIException):
+# The recommended style for using `ValidationError` is to keep it namespaced
+# under `serializers`, in order to minimize potential confusion with Django's
+# built in `ValidationError`. For example:
+#
+# from rest_framework import serializers
+# raise serializers.ValidationError('Value was invalid')
+
+class ValidationError(APIException):
status_code = status.HTTP_400_BAD_REQUEST
def __init__(self, detail):