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
2ef74cfa
Commit
2ef74cfa
authored
Mar 13, 2016
by
Carlton Gibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bring check for null fk to `BaseSerializer.to_representation`
parent
cbb8d8d2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
rest_framework/fields.py
+0
-2
rest_framework/serializers.py
+7
-3
No files found.
rest_framework/fields.py
View file @
2ef74cfa
...
@@ -778,8 +778,6 @@ class UUIDField(Field):
...
@@ -778,8 +778,6 @@ class UUIDField(Field):
return
data
return
data
def
to_representation
(
self
,
value
):
def
to_representation
(
self
,
value
):
if
value
is
None
:
return
None
if
self
.
uuid_format
==
'hex_verbose'
:
if
self
.
uuid_format
==
'hex_verbose'
:
return
str
(
value
)
return
str
(
value
)
else
:
else
:
...
...
rest_framework/serializers.py
View file @
2ef74cfa
...
@@ -464,9 +464,13 @@ class Serializer(BaseSerializer):
...
@@ -464,9 +464,13 @@ class Serializer(BaseSerializer):
except
SkipField
:
except
SkipField
:
continue
continue
if
attribute
is
None
:
# We skip `to_representation` for `None` values so that fields do
# We skip `to_representation` for `None` values so that
# not have to explicitly deal with that case.
# fields do not have to explicitly deal with that case.
#
# For related fields with `use_pk_only_optimization` we need to
# resolve the pk value.
check_for_none
=
attribute
.
pk
if
isinstance
(
attribute
,
PKOnlyObject
)
else
attribute
if
check_for_none
is
None
:
ret
[
field
.
field_name
]
=
None
ret
[
field
.
field_name
]
=
None
else
:
else
:
ret
[
field
.
field_name
]
=
field
.
to_representation
(
attribute
)
ret
[
field
.
field_name
]
=
field
.
to_representation
(
attribute
)
...
...
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