报这个错的原因是因为json.dumps函数发现字典里面有bytes类型的数据,无法编码。解决方法:将bytes类型的数据就把它转化成str类型。
定义dates[]后return JsonResponse({‘status’: 200,’message’:’success’,’data’:datas})报上述错误
解决方法:return JsonResponse({‘status’: 200,’message’:’success’,’data’:str(datas)})
报错:CSRF token missing or incorrect.
解决方法:在view文件中加入装饰器@csrf_exemp
代码如下:
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt def contact(request):
django之所以引进CSRF是为了避免Cross Site Request Forgeries攻击,而上面的解决方法恰好禁止掉这个django的功能。
转载于:https://www.cnblogs.com/jieliu8080/p/10868517.html
原文链接:https://blog.csdn.net/weixin_30342827/article/details/95220704
本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。
评论前必须登录!
立即登录