mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-05 13:00:12 +03:00
Add custom separators support to JSONRenderer
Allow custom separators for the JSONRenderer by sending a 'separators' item in your `renderer_context`.
This commit is contained in:
parent
4f27b966a5
commit
d8ee1389b8
|
@ -90,7 +90,9 @@ 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
|
||||
separators = renderer_context.get(
|
||||
'separators',
|
||||
SHORT_SEPARATORS if (indent is None and self.compact) else LONG_SEPARATORS)
|
||||
|
||||
ret = json.dumps(
|
||||
data, cls=self.encoder_class,
|
||||
|
|
Loading…
Reference in New Issue
Block a user