use JsonResponse in html js django code example Example: jsonresponse django from django.http import JsonResponse return JsonResponse({'foo':'bar'})