raise ValueError The view users.views.LoginView didn't return an HttpResponse object. It returned None instead.

发生这个的原因,是因为Django需要返回HttpResponse信息,而我们没有给return返回数据

[28/Oct/2021 19:34:48] "OPTIONS /login/ HTTP/1.1" 200 0
Internal Server Error: /login/
Traceback (most recent call last):
  File "D:\myenv\FinancialBackend\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
    response = get_response(request)
  File "D:\myenv\FinancialBackend\lib\site-packages\django\core\handlers\base.py", line 188, in _get_response
    self.check_response(response, callback)
  File "D:\myenv\FinancialBackend\lib\site-packages\django\core\handlers\base.py", line 309, in check_response
    raise ValueError(
ValueError: The view users.views.LoginView didn't return an HttpResponse object. It returned None instead.
[28/Oct/2021 19:34:49] "POST /login/ HTTP/1.1" 500 75069
出错代码
http.JsonResponse({'status': 200, 'token': token, 'msg': '登录认证成功!'})
修改的python代码
return http.JsonResponse({'status': 200, 'token': 'token', 'msg': '登录认证成功!'})