Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Docstrings
  • Loading branch information
lovelydinosaur committed Oct 10, 2016
commit 2a3d07d9d3b8ca0ff8e6b142eb3d68097d67df21
2 changes: 1 addition & 1 deletion docs/api-guide/exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ By default this exception results in a response with the HTTP status code "429 T

## ValidationError

**Signature:** `ValidationError(detail)`
**Signature:** `ValidationError(detail, code=None)`

The `ValidationError` exception is slightly different from the other `APIException` classes:

Expand Down
10 changes: 10 additions & 0 deletions rest_framework/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,19 @@ def __str__(self):
return six.text_type(self.detail)

def get_codes(self):
"""
Return only the code part of the error details.

Eg. {"name": ["required"]}
"""
return _get_codes(self.detail)

def get_full_details(self):
"""
Return both the message & code parts of the error details.

Eg. {"name": [{"message": "This field is required.", "code": "required"}]}
"""
return _get_full_details(self.detail)


Expand Down