Django ValueError: HTTP status code must be an integer from 100 to 599.

程序执行后一直提示ValueError: HTTP status code must be an integer from 100 to 599.

 

遍历代码一切正常,然后开始调试代码,找出获取数据有问题,直接到except中,按理来讲也只是报{code=10020, msg='param error'}

        try:

            data = JSONParser().parse(request)

        except:
            return JsonResponse(code=10020, msg='param error')

将try...except注释,再次运行提示{"detail":"JSON parse error - Expecting ',' delimiter: line 3 column 2 (char 14)"},json格式不对,修改格式

 

 

 再次运行,发现还是提示ValueError: HTTP status code must be an integer from 100 to 599.

 

 

 再次审查代码,发现JsonResponse()参数传入有误

 

 

 将status改为code

 

 再次run,不会报奇怪的问题

 

 总结:粗心大意浪费时间,细节很重要!!!!!!!

 

posted @ 2020-09-11 17:32  **绵绵羊**  阅读(1167)  评论(0编辑  收藏  举报