TypeError:类型为'JsonResponse'的对象在返回json值时没有len()。但是print(dicts)和print(json.dumps(dicts)),它显示了值,但是当返回JsonResponse(json.dumps(dicts),safe=False)显示一个错误,如“TypeError:'JsonResponse'类型的对象没有len()',如何解决这个问题。错误Internal Server Error: /api/v2/usernewslist/Traceback (most recent call last):File "C:\duklr\Duklr-web\venv\lib\site- packages\django\core\handlers\exception.py", line 41, in innerresponse = get_response(request)File "C:\duklr\Duklr-web\venv\lib\site- packages\django\core\handlers\base.py", line 187, in _get_responseresponse = self.process_exception_by_middleware(e, request)File "C:\duklr\Duklr-web\venv\lib\site- packages\django\core\handlers\base.py", line 185, in _get_responseresponse = wrapped_callback(request, *callback_args, **callback_kwargs)File "C:\duklr\Duklr-web\venv\lib\site- packages\django\views\decorators\csrf.py", line 58, in wrapped_viewreturn view_func(*args, **kwargs)File "C:\duklr\Duklr-web\venv\lib\site-packages\rest_framework\viewsets.py", line 116, in viewreturn self.dispatch(request, *args, **kwargs)File "C:\duklr\Duklr-web\venv\lib\site-packages\rest_framework\views.py", line 495, in dispatchresponse = self.handle_exception(exc)File "C:\duklr\Duklr-web\venv\lib\site-packages\rest_framework\views.py", line 455, in handle_exceptionself.raise_uncaught_exception(exc) File "C:\duklr\Duklr-web\venv\lib\site-packages\rest_framework\views.py", line 492, in dispatchresponse = handler(request, *args, **kwargs) File "C:\duklr\Duklr-web\venv\lib\site-packages\rest_framework\mixins.py", line 42, in list
添加回答
举报
0/150
提交
取消