ERROR exception 135 Internal Server Error: /apple/login/ Traceback (most recent call last): File "/home/python/.virtualenvs/py3/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner response = get_response(request) File "/home/python/.virtualenvs/py3/lib/python3.5/site-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/python/.virtualenvs/py3/lib/python3.5/site-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/python/.virtualenvs/py3/lib/python3.5/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view return view_func(*args, **kwargs) File "/home/python/.virtualenvs/py3/lib/python3.5/site-packages/django/views/generic/base.py", line 68, in view return self.dispatch(request, *args, **kwargs) File "/home/python/.virtualenvs/py3/lib/python3.5/site-packages/rest_framework/views.py", line 483, in dispatch response = self.handle_exception(exc) File "/home/python/.virtualenvs/py3/lib/python3.5/site-packages/rest_framework/views.py", line 443, in handle_exception self.raise_uncaught_exception(exc) File "/home/python/.virtualenvs/py3/lib/python3.5/site-packages/rest_framework/views.py", line 480, in dispatch response = handler(request, *args, **kwargs) File "/home/python/Desktop/dongliang/dongliang/apps/wechat/views.py", line 661, in post response = applet.create_token(encryptedData, iv) File "/home/python/Desktop/dongliang/dongliang/apps/wechat/applet_utls.py", line 68, in create_token oauth_user = OAuthUser.objects.get(weixin_unionid=user_dict_data['unionid']) KeyError: 'unionid' ERROR basehttp 124 "POST /apple/login/ HTTP/1.1" 500 21729 Performing system checks...
解决和错误原因
oauth_user = OAuthUser.objects.get(weixin_unionid=user_dict_data['unionid'])
取不到 unionid
原来是 unionId
注意细节