Skip to content

Commit

Permalink
fix antipattern: use JsonResponse as intended
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed Apr 9, 2024
1 parent a01fc41 commit 2e40d24
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions cms/utils/admin.py
@@ -1,6 +1,4 @@
import json

from django.http import HttpResponse
from django.http import JsonResponse
from django.utils.encoding import smart_str

NOT_FOUND_RESPONSE = "NotFound"
Expand All @@ -13,4 +11,4 @@ def jsonify_request(response):
* content: original response content
"""
content = {'status': response.status_code, 'content': smart_str(response.content, response.charset)}
return HttpResponse(json.dumps(content), content_type="application/json")
return JsonResponse(content)

0 comments on commit 2e40d24

Please sign in to comment.