Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
69e62457
Commit
69e62457
authored
Jan 23, 2013
by
Stephan Groß
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve validate_<fieldname> fix
parent
f0071dbc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
rest_framework/serializers.py
+9
-8
No files found.
rest_framework/serializers.py
View file @
69e62457
...
@@ -227,14 +227,15 @@ class BaseSerializer(Field):
...
@@ -227,14 +227,15 @@ class BaseSerializer(Field):
Run `validate_<fieldname>()` and `validate()` methods on the serializer
Run `validate_<fieldname>()` and `validate()` methods on the serializer
"""
"""
for
field_name
,
field
in
self
.
fields
.
items
():
for
field_name
,
field
in
self
.
fields
.
items
():
if
field_name
not
in
self
.
_errors
:
if
field_name
in
self
.
_errors
:
try
:
continue
validate_method
=
getattr
(
self
,
'validate_
%
s'
%
field_name
,
None
)
try
:
if
validate_method
:
validate_method
=
getattr
(
self
,
'validate_
%
s'
%
field_name
,
None
)
source
=
field
.
source
or
field_name
if
validate_method
:
attrs
=
validate_method
(
attrs
,
source
)
source
=
field
.
source
or
field_name
except
ValidationError
as
err
:
attrs
=
validate_method
(
attrs
,
source
)
self
.
_errors
[
field_name
]
=
self
.
_errors
.
get
(
field_name
,
[])
+
list
(
err
.
messages
)
except
ValidationError
as
err
:
self
.
_errors
[
field_name
]
=
self
.
_errors
.
get
(
field_name
,
[])
+
list
(
err
.
messages
)
# If there are already errors, we don't run .validate() because
# If there are already errors, we don't run .validate() because
# field-validation failed and thus `attrs` may not be complete.
# field-validation failed and thus `attrs` may not be complete.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment