在我的 django 项目中,为了避免另一个请求,我想返回一个带有 HttpResponse 的 JsonResponse,如下所示:
JsonResponse({"known": True, "space": render(request, 'space.html')}, status=200)
Django进程返回正常的内部错误Object of type HttpResponse is not JSON serializable
我尝试了所有的网络解决方案(序列化器等),但找不到一种方法来返回带有字典条目的 json 格式(我的 javascript 必需的),其中一个是我可以与 then 一起使用的整个 html 页面$("body").html(response["space"])。
我错过了什么吗?
谢谢你的时间。