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
cd40dcb0
Commit
cd40dcb0
authored
Oct 30, 2014
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure json.dumps(separators=...) works on both 2.x and 3.x
parent
0dea509d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
rest_framework/compat.py
+9
-0
rest_framework/renderers.py
+4
-2
No files found.
rest_framework/compat.py
View file @
cd40dcb0
...
...
@@ -291,6 +291,15 @@ except ImportError:
oauth2_constants
=
None
provider_now
=
None
# `seperators` argument to `json.dumps()` differs between 2.x and 3.x
# See: http://bugs.python.org/issue22767
if
six
.
PY3
:
SHORT_SEPARATORS
=
(
','
,
':'
)
LONG_SEPARATORS
=
(
', '
,
': '
)
else
:
SHORT_SEPARATORS
=
(
b
','
,
b
':'
)
LONG_SEPARATORS
=
(
b
', '
,
b
': '
)
# Handle lazy strings across Py2/Py3
from
django.utils.functional
import
Promise
...
...
rest_framework/renderers.py
View file @
cd40dcb0
...
...
@@ -18,7 +18,9 @@ from django.test.client import encode_multipart
from
django.utils
import
six
from
django.utils.xmlutils
import
SimplerXMLGenerator
from
rest_framework
import
exceptions
,
serializers
,
status
,
VERSION
from
rest_framework.compat
import
StringIO
,
smart_text
,
yaml
from
rest_framework.compat
import
(
SHORT_SEPARATORS
,
LONG_SEPARATORS
,
StringIO
,
smart_text
,
yaml
)
from
rest_framework.exceptions
import
ParseError
from
rest_framework.settings
import
api_settings
from
rest_framework.request
import
is_form_media_type
,
override_method
...
...
@@ -87,7 +89,7 @@ class JSONRenderer(BaseRenderer):
renderer_context
=
renderer_context
or
{}
indent
=
self
.
get_indent
(
accepted_media_type
,
renderer_context
)
separators
=
(
','
,
':'
)
if
(
indent
is
None
and
self
.
compact
)
else
(
', '
,
': '
)
separators
=
SHORT_SEPARATORS
if
(
indent
is
None
and
self
.
compact
)
else
LONG_SEPARATORS
ret
=
json
.
dumps
(
data
,
cls
=
self
.
encoder_class
,
...
...
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