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
48fa77c0
Commit
48fa77c0
authored
Feb 04, 2015
by
José Padilla
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add child to ListField when using ArrayField
parent
b844cc4b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
rest_framework/serializers.py
+10
-0
No files found.
rest_framework/serializers.py
View file @
48fa77c0
...
@@ -986,15 +986,25 @@ class ModelSerializer(Serializer):
...
@@ -986,15 +986,25 @@ class ModelSerializer(Serializer):
# Fields with choices get coerced into `ChoiceField`
# Fields with choices get coerced into `ChoiceField`
# instead of using their regular typed field.
# instead of using their regular typed field.
field_class
=
ChoiceField
field_class
=
ChoiceField
if
not
issubclass
(
field_class
,
ModelField
):
if
not
issubclass
(
field_class
,
ModelField
):
# `model_field` is only valid for the fallback case of
# `model_field` is only valid for the fallback case of
# `ModelField`, which is used when no other typed field
# `ModelField`, which is used when no other typed field
# matched to the model field.
# matched to the model field.
field_kwargs
.
pop
(
'model_field'
,
None
)
field_kwargs
.
pop
(
'model_field'
,
None
)
if
not
issubclass
(
field_class
,
CharField
)
and
not
issubclass
(
field_class
,
ChoiceField
):
if
not
issubclass
(
field_class
,
CharField
)
and
not
issubclass
(
field_class
,
ChoiceField
):
# `allow_blank` is only valid for textual fields.
# `allow_blank` is only valid for textual fields.
field_kwargs
.
pop
(
'allow_blank'
,
None
)
field_kwargs
.
pop
(
'allow_blank'
,
None
)
if
postgres_fields
and
isinstance
(
model_field
,
postgres_fields
.
ArrayField
):
child_model_field
=
model_field
.
base_field
.
base_field
child_field_class
,
child_field_kwargs
=
self
.
build_standard_field
(
'child'
,
child_model_field
)
field_kwargs
[
'child'
]
=
child_field_class
(
**
child_field_kwargs
)
return
field_class
,
field_kwargs
return
field_class
,
field_kwargs
def
build_relational_field
(
self
,
field_name
,
relation_info
):
def
build_relational_field
(
self
,
field_name
,
relation_info
):
...
...
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