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
e0913e29
Commit
e0913e29
authored
Sep 25, 2012
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some bits of serialization
parent
4fb57d28
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
8 deletions
+10
-8
rest_framework/fields.py
+7
-4
rest_framework/serializers.py
+3
-3
rest_framework/templatetags/rest_framework.py
+0
-1
No files found.
rest_framework/fields.py
View file @
e0913e29
...
...
@@ -42,7 +42,11 @@ class Field(object):
self
.
source
=
source
self
.
readonly
=
readonly
self
.
required
=
not
(
readonly
)
if
required
is
None
:
self
.
required
=
not
(
readonly
)
else
:
assert
not
readonly
,
"Cannot set required=True and readonly=True"
self
.
required
=
required
messages
=
{}
for
c
in
reversed
(
self
.
__class__
.
__mro__
):
...
...
@@ -66,9 +70,8 @@ class Field(object):
self
.
model_field
=
model_field
def
validate
(
self
,
value
):
pass
# if value in validators.EMPTY_VALUES and self.required:
# raise ValidationError(self.error_messages['required'])
if
value
in
validators
.
EMPTY_VALUES
and
self
.
required
:
raise
ValidationError
(
self
.
error_messages
[
'required'
])
def
run_validators
(
self
,
value
):
if
value
in
validators
.
EMPTY_VALUES
:
...
...
rest_framework/serializers.py
View file @
e0913e29
...
...
@@ -95,7 +95,7 @@ class BaseSerializer(Field):
self
.
context
=
context
or
{}
self
.
init_data
=
data
self
.
instance
=
instance
self
.
object
=
instance
self
.
_data
=
None
self
.
_errors
=
None
...
...
@@ -247,7 +247,7 @@ class BaseSerializer(Field):
self
.
_errors
=
{}
attrs
=
self
.
restore_fields
(
data
)
if
not
self
.
_errors
:
return
self
.
restore_object
(
attrs
,
instance
=
getattr
(
self
,
'
instance
'
,
None
))
return
self
.
restore_object
(
attrs
,
instance
=
getattr
(
self
,
'
object
'
,
None
))
@property
def
errors
(
self
):
...
...
@@ -267,7 +267,7 @@ class BaseSerializer(Field):
@property
def
data
(
self
):
if
self
.
_data
is
None
:
self
.
_data
=
self
.
to_native
(
self
.
instance
)
self
.
_data
=
self
.
to_native
(
self
.
object
)
return
self
.
_data
...
...
rest_framework/templatetags/rest_framework.py
View file @
e0913e29
...
...
@@ -103,7 +103,6 @@ def add_class(value, css_class):
m
=
re
.
search
(
r'^
%
s$|^
%
s\s|\s
%
s\s|\s
%
s$'
%
(
css_class
,
css_class
,
css_class
,
css_class
),
match
.
group
(
1
))
print
match
.
group
(
1
)
if
not
m
:
return
mark_safe
(
class_re
.
sub
(
match
.
group
(
1
)
+
" "
+
css_class
,
html
))
...
...
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