【发布时间】:2020-06-28 14:45:37
【问题描述】:
在我的 django 项目中,为了避免另一个请求,我想返回一个带有 HttpResponse 的 JsonResponse,如下所示:
JsonResponse({"known": True, "space": render(request, 'space.html')}, status=200)
Django进程返回正常内部错误Object of type HttpResponse is not JSON serializable
我尝试了所有的网络解决方案(序列化器等),但找不到一种方法来返回带有字典条目的 json 格式(我的 javascript 所必需的),其中一个是我可以使用的整个 html 页面$("body").html(response["space"])。
我错过了什么吗?
感谢您的宝贵时间。
【问题讨论】:
标签: python django serialization httpresponse jsonresponse