mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-01 11:00:13 +03:00
resolve #6555 add status_code in constructor of ValidationError
This commit is contained in:
parent
1ac0f63aa9
commit
0b2948ccb7
|
@ -144,11 +144,13 @@ class ValidationError(APIException):
|
||||||
default_detail = _('Invalid input.')
|
default_detail = _('Invalid input.')
|
||||||
default_code = 'invalid'
|
default_code = 'invalid'
|
||||||
|
|
||||||
def __init__(self, detail=None, code=None):
|
def __init__(self, detail=None, code=None, status_code=None):
|
||||||
if detail is None:
|
if detail is None:
|
||||||
detail = self.default_detail
|
detail = self.default_detail
|
||||||
if code is None:
|
if code is None:
|
||||||
code = self.default_code
|
code = self.default_code
|
||||||
|
if status_code:
|
||||||
|
self.status_code = status_code
|
||||||
|
|
||||||
# For validation failures, we may collect many errors together,
|
# For validation failures, we may collect many errors together,
|
||||||
# so the details should always be coerced to a list if not already.
|
# so the details should always be coerced to a list if not already.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user