我目前正在尝试在django中为一个web应用程序设置带有social-auth的社交登录。每当我单击链接到google登录的网页上的按钮时,django网页上都会出现以下错误:
ModuleNotFoundError at /oauth/login/google-oauth2/
No module named 'social_core.backends.google.GoogleOAuth2django'; 'social_core.backends.google' is not a package
Request Method: GET
Request URL: http://127.0.0.1:8000/oauth/login/google-oauth2/
Django Version: 3.0.5
Exception Type: ModuleNotFoundError
Exception Value:
No module named 'social_core.backends.google.GoogleOAuth2django'; 'social_core.backends.google' is not a package
Exception Location: C:\Users\isaac\OneDrive\Desktop\DeliverMeProj\venv\lib\site-packages\social_core\utils.py in import_module, line 56
Python Executable: C:\Users\isaac\OneDrive\Desktop\DeliverMeProj\venv\Scripts\python.exe
Python Version: 3.8.2
Python Path:
['C:\\Users\\isaac\\OneDrive\\Desktop\\DeliverMeProj',
'C:\\Program Files\\Python38\\python38.zip',
'C:\\Program Files\\Python38\\DLLs',
'C:\\Program Files\\Python38\\lib',
'C:\\Program Files\\Python38',
'C:\\Users\\isaac\\OneDrive\\Desktop\\DeliverMeProj\\venv',
'C:\\Users\\isaac\\OneDrive\\Desktop\\DeliverMeProj\\venv\\lib\\site-packages',
'C:\\Users\\isaac\\AppData\\Roaming\\Python\\Python38\\site-packages',
'C:\\Program Files\\Python38\\lib\\site-packages']
Server time: Sun, 26 Apr 2020 04:12:34 +0000你知道为什么会发生这种情况吗?
发布于 2020-04-26 12:57:11
我真的想通了。我的AUTHENTICATIONBACKEND部分缺少一个逗号。
所以问题看起来是这样的:
AUTHENTICATION_BACKENDS = (
'social_core.backends.google.GoogleOAuth2'
'django.contrib.auth.backends.ModelBackend',)
解决方案是:
AUTHENTICATION_BACKENDS = (
'social_core.backends.google.GoogleOAuth2',
'django.contrib.auth.backends.ModelBackend',)
发布于 2020-04-26 12:32:03
您是否安装了python-social-auth模块
请尝试这个pip安装python-social-auth
有关详细信息,请参阅here。
还要确保您的settings.py文件定义了所有依赖项
您也可以尝试这个新的库social_core。
https://stackoverflow.com/questions/61435766
复制相似问题