aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework
diff options
context:
space:
mode:
Diffstat (limited to 'rest_framework')
-rw-r--r--rest_framework/compat.py2
-rw-r--r--rest_framework/renderers.py8
2 files changed, 8 insertions, 2 deletions
diff --git a/rest_framework/compat.py b/rest_framework/compat.py
index 7241da27..ea342994 100644
--- a/rest_framework/compat.py
+++ b/rest_framework/compat.py
@@ -227,6 +227,8 @@ except ImportError:
if six.PY3:
SHORT_SEPARATORS = (',', ':')
LONG_SEPARATORS = (', ', ': ')
+ INDENT_SEPARATORS = (',', ': ')
else:
SHORT_SEPARATORS = (b',', b':')
LONG_SEPARATORS = (b', ', b': ')
+ INDENT_SEPARATORS = (b',', b': ')
diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py
index 4c46b049..7af03c67 100644
--- a/rest_framework/renderers.py
+++ b/rest_framework/renderers.py
@@ -18,7 +18,7 @@ from django.template import Context, RequestContext, loader, Template
from django.test.client import encode_multipart
from django.utils import six
from rest_framework import exceptions, serializers, status, VERSION
-from rest_framework.compat import SHORT_SEPARATORS, LONG_SEPARATORS
+from rest_framework.compat import SHORT_SEPARATORS, LONG_SEPARATORS, INDENT_SEPARATORS
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 +87,11 @@ class JSONRenderer(BaseRenderer):
renderer_context = renderer_context or {}
indent = self.get_indent(accepted_media_type, renderer_context)
- separators = SHORT_SEPARATORS if (indent is None and self.compact) else LONG_SEPARATORS
+
+ if indent is None:
+ separators = SHORT_SEPARATORS if self.compact else LONG_SEPARATORS
+ else:
+ separators = INDENT_SEPARATORS
ret = json.dumps(
data, cls=self.encoder_class,