diff --git a/rest_framework/exceptions.py b/rest_framework/exceptions.py index f79b16129..1a22879e1 100644 --- a/rest_framework/exceptions.py +++ b/rest_framework/exceptions.py @@ -144,11 +144,13 @@ class ValidationError(APIException): default_detail = _('Invalid input.') default_code = 'invalid' - def __init__(self, detail=None, code=None): + def __init__(self, detail=None, code=None, status_code=None): if detail is None: detail = self.default_detail if code is None: code = self.default_code + if status_code: + self.status_code = status_code # For validation failures, we may collect many errors together, # so the details should always be coerced to a list if not already.