python中这个错误的原因是字段为datetime,无法序列化对象
网上其他方法是重写构造json类,遇到日期特殊处理,其余的用内置的就行。
我这里没有重写json类,封装了一个时间转换类
可参考我的这篇文章
https://blog.csdn.net/hans99812345/article/details/110196293
实例化这个类
operation = OperationTime()
login_time = operation.datetime_to_strdatetime(webmail_login_time['login_time'])
webmail_login_time['login_time'] = login_time
return HttpResponse(json.dumps(webmail_login_time), content_type="application/json")
这样就可以了