Skip to content

Django HTTP

JsonResponse

At Forma, we had a custom JsonResponse

JsonResponse docs

response = JsonResponse({'foo': 'bar'}, status=200)

Returning an array

  • security vulnerability before ES5
  • you should return an object anyway
    • easier to add/remove stuff in the future
response = JsonResponse([1, 2, 3], safe=False)

Last update: 2022-11-04