From d0f9432add5b98bad11ae0632a65cf845d4dd5cc Mon Sep 17 00:00:00 2001 From: Mads Jensen Date: Tue, 13 Feb 2018 09:15:47 +0100 Subject: [PATCH] Simplified wiki.core.utils.object_to_json_response. --- src/wiki/core/utils.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/wiki/core/utils.py b/src/wiki/core/utils.py index b90bda9b..26b617d4 100644 --- a/src/wiki/core/utils.py +++ b/src/wiki/core/utils.py @@ -1,10 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -import json from importlib import import_module -from django.http.response import HttpResponse +from django.http.response import JsonResponse def get_class_from_str(class_path): @@ -20,7 +19,6 @@ def object_to_json_response(obj, status=200): Given an object, returns an HttpResponse object with a JSON serialized version of that object """ - data = json.dumps(obj, ensure_ascii=False) - response = HttpResponse(content_type='application/json', status=status) - response.write(data) - return response + return JsonResponse( + data=obj, status=status, safe=False, json_dumps_params={'ensure_ascii': False}, + ) -- 2.45.2