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
899233bf
Commit
899233bf
authored
Mar 09, 2011
by
spiq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamings + corrected a bug
parent
d053cc89
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
djangorestframework/parsers.py
+9
-9
No files found.
djangorestframework/parsers.py
View file @
899233bf
...
@@ -82,23 +82,23 @@ class DataFlatener(object):
...
@@ -82,23 +82,23 @@ class DataFlatener(object):
#TODO : document + test
#TODO : document + test
def
flatten_data
(
self
,
data
):
def
flatten_data
(
self
,
data
):
"""Given a data dictionary ``{<
attr_name
>: <value_list>}``, returns a flattened dictionary according to :meth:`FormParser.is_a_list`.
"""Given a data dictionary ``{<
key
>: <value_list>}``, returns a flattened dictionary according to :meth:`FormParser.is_a_list`.
"""
"""
flatdata
=
dict
()
flatdata
=
dict
()
for
attr_name
,
attr_value
in
data
.
items
():
for
key
,
attr_value
in
data
.
items
():
if
self
.
is_a_list
(
attr_name
):
if
self
.
is_a_list
(
key
):
if
isinstance
(
attr_value
,
list
):
if
isinstance
(
attr_value
,
list
):
flatdata
[
attr_name
]
=
attr_value
flatdata
[
key
]
=
attr_value
else
:
else
:
flatdata
[
attr_name
]
=
[
attr_value
]
flatdata
[
key
]
=
[
attr_value
]
else
:
else
:
if
isinstance
(
attr_value
,
list
):
if
isinstance
(
attr_value
,
list
):
flatdata
[
attr_name
]
=
attr_value
[
0
]
flatdata
[
key
]
=
attr_value
[
0
]
else
:
else
:
flatdata
[
attr_name
]
=
attr_value
flatdata
[
key
]
=
attr_value
return
flatdata
return
flatdata
def
is_a_list
(
self
,
attr_name
):
def
is_a_list
(
self
,
key
):
""" """
""" """
return
False
return
False
...
@@ -120,7 +120,7 @@ class FormParser(BaseParser, DataFlatener):
...
@@ -120,7 +120,7 @@ class FormParser(BaseParser, DataFlatener):
data
=
parse_qs
(
input
)
data
=
parse_qs
(
input
)
elif
request
.
method
==
'POST'
:
elif
request
.
method
==
'POST'
:
# Django has already done the form parsing for us.
# Django has already done the form parsing for us.
data
=
request
.
POST
data
=
dict
(
request
.
POST
.
iterlists
())
# Flatening data and removing EMPTY_VALUEs from the lists
# Flatening data and removing EMPTY_VALUEs from the lists
data
=
self
.
flatten_data
(
data
)
data
=
self
.
flatten_data
(
data
)
...
...
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