搞第三方授权登录的时候
完整报错如下:
DoesNotExist at /accounts/github/login/
SocialApp matching query does not exist.
Request Method: | GET |
---|---|
Request URL: | http://127.0.0.1:8000/accounts/github/login/?process=login |
Django Version: | 2.2.10 |
Exception Type: | DoesNotExist |
Exception Value: | |
Exception Location: | /home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/db/models/query.py in get, line 408 |
Python Executable: | /home/appleyuchi/.virtualenvs/python3.7/bin/python |
Python Version: | 3.7.5 |
Python Path: | |
Server time: | Sun, 1 Mar 2020 04:44:56 +0000 |
先说下Django中SITE_ID的意思,其实是admin里面的站点的第几个,
默认情况下SITE_ID=1
建议删除http://127.0.0.1:8000/admin/界面中没用的SITE,留一个就行了,如果多个SITE都有用,那么
在settings.py中修改SITE_ID的取值即可
不确定SITE_ID的取值的情况下,可以使用:
python manage.py shell
from django.contrib.sites.models import Site
print(Site.objects.get(name='example.com').id)
解决方案,检查3个东西:
①settings.py中的SITE_ID的数值以及INSTALLED_APPS中的
'allauth.socialaccount.providers.github',
②检查站点名称
③增加共享登录
http://127.0.0.1:8000/admin/socialaccount/socialapp/add/