diff options
Diffstat (limited to 'django/http')
| -rw-r--r-- | django/http/response.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/django/http/response.py b/django/http/response.py index aece5ec5a6..b42f0b51d3 100644 --- a/django/http/response.py +++ b/django/http/response.py @@ -492,12 +492,16 @@ class JsonResponse(HttpResponse): ``django.core.serializers.json.DjangoJSONEncoder``. :param safe: Controls if only ``dict`` objects may be serialized. Defaults to ``True``. + :param json_dumps_params: A dictionary of kwargs passed to json.dumps(). """ - def __init__(self, data, encoder=DjangoJSONEncoder, safe=True, **kwargs): + def __init__(self, data, encoder=DjangoJSONEncoder, safe=True, + json_dumps_params=None, **kwargs): if safe and not isinstance(data, dict): raise TypeError('In order to allow non-dict objects to be ' 'serialized set the safe parameter to False') + if json_dumps_params is None: + json_dumps_params = {} kwargs.setdefault('content_type', 'application/json') - data = json.dumps(data, cls=encoder) + data = json.dumps(data, cls=encoder, **json_dumps_params) super(JsonResponse, self).__init__(content=data, **kwargs) |
