'NoneType' object has no attribute 'username' 提交用户注册信息报错了
来源:7-14 vue和注册功能联调
Hanamichi520
2020-11-08
老师,提交用户注册信息报错了,检查了代码,跟你讲的是一样的。请老师帮忙看看,到底那里有问题
AttributeError at /users/
'NoneType' object has no attribute 'username'
Request Method: POST
Request URL: http://127.0.0.1:9999/users/
Django Version: 3.1.1
Exception Type: AttributeError
Exception Value:
'NoneType' object has no attribute 'username'
Exception Location: H:\Evns\MxShop\lib\site-packages\rest_framework_jwt\compat.py, line 35, in get_username
Python Executable: H:\Evns\MxShop\Scripts\python3.8.exe
Python Version: 3.8.0
Python Path:
['H:\\MxsShop',
'H:\\MxsShop',
'D:\\Program Files\\JetBrains\\PyCharm '
'2019.2\\plugins\\python\\helpers\\pycharm_display',
'H:\\Evns\\MxShop\\Scripts\\python38.zip',
'd:\\python\\python38-32\\DLLs',
'd:\\python\\python38-32\\lib',
'd:\\python\\python38-32',
'H:\\Evns\\MxShop',
'H:\\Evns\\MxShop\\lib\\site-packages',
'D:\\Program Files\\JetBrains\\PyCharm '
'2019.2\\plugins\\python\\helpers\\pycharm_matplotlib_backend']
Server time: Sun, 08 Nov 2020 12:33:07 +0800
Traceback (most recent call last):
File "H:\Evns\MxShop\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
response = get_response(request)
File "H:\Evns\MxShop\lib\site-packages\django\core\handlers\base.py", line 179, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "H:\Evns\MxShop\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "H:\Evns\MxShop\lib\site-packages\rest_framework\viewsets.py", line 114, in view
return self.dispatch(request, *args, **kwargs)
File "H:\Evns\MxShop\lib\site-packages\rest_framework\views.py", line 505, in dispatch
response = self.handle_exception(exc)
File "H:\Evns\MxShop\lib\site-packages\rest_framework\views.py", line 465, in handle_exception
self.raise_uncaught_exception(exc)
File "H:\Evns\MxShop\lib\site-packages\rest_framework\views.py", line 476, in raise_uncaught_exception
raise exc
File "H:\Evns\MxShop\lib\site-packages\rest_framework\views.py", line 502, in dispatch
response = handler(request, *args, **kwargs)
File "H:\MxsShop\apps\users\views.py", line 79, in create
payload = jwt_payload_handler(user)
File "H:\Evns\MxShop\lib\site-packages\rest_framework_jwt\utils.py", line 34, in jwt_payload_handler
username = get_username(user)
File "H:\Evns\MxShop\lib\site-packages\rest_framework_jwt\compat.py", line 35, in get_username
username = user.username
AttributeError: 'NoneType' object has no attribute 'username'
写回答
1回答
-
bobby
2020-11-10
你的userprofile这个model的源码截图我看看
00
Python前后端分离开发Vue+Django REST framework实战
Django REST framework课程视频,RESTFul API前后端分离开发
2906 学习 · 2491 问题
相似问题