Hopetree / izone

一个基于Django的博客项目,也可以当做一个文档管理网站使用,自带评论、定时任务等功能,界面简约而不简单
https://tendcode.com
MIT License
1.17k stars 373 forks source link

注册 -> 快捷登录处选"微博"或者"Github" 后提示报错 #125

Closed qiutzh closed 3 years ago

qiutzh commented 4 years ago

@Hopetree 博主您好,如题,我在选择微博注册或者Github注册时,页面有以下错误提示:

# 选择Github注册
DoesNotExist at /accounts/github/login/
SocialApp matching query does not exist.

# 选择微博注册
DoesNotExist at /accounts/weibo/login/
SocialApp matching query does not exist.

请问怎么解决呢?感谢!

Hopetree commented 4 years ago

@qiutzh 你说的是我的网站还是你用我代码部署的?如果是我的网站应该不存在这个问题,而且这两个方式也不是注册,而是登录。

如果你部署的,那么你需要进入管理界面,添加github和微博的接口,具体是在后台的Social applications中添加,这个你可以查一下django-allauth的用法

qiutzh commented 4 years ago

哦,多谢大佬,我是利用代码部署的哈。

qiutzh commented 4 years ago

@Hopetree 博主帮我看下,我这样配置的github第三方登录问题出在哪了呢?

settings.py


AUTHENTICATION_BACKENDS = {
    ...
    'social_core.backends.github.GithubOAuth2',
}

INSTALLED_APPS = [
    ...
    'social_django', 
]

TEMPLATES = [
    ...
    'social_django.context_processors.backends',
    'social_django.context_processors.login_redirect',
]

SOCIAL_AUTH_GITHUB_KEY = 'xxx'
SOCIAL_AUTH_GITHUB_SECRET = 'xxxxxx'

urls.py

urlpatterns = [
    ...
    path('accounts/github/login/', auth_views.LoginView.as_view(), name='login'),
    path('accounts/github/login/callback/', include('social_django.urls', namespace='social')),
]

做了以上这些配置后,然后启动web服务,点击选择github方式登录,还是报了错

Internal Server Error: /accounts/github/login/
allauth.socialaccount.models.SocialApp.DoesNotExist: SocialApp matching query does not exist.

后面我登录到后台,把github的Client id和Secret key填上,添加sites站点后,再次启动点击github登录上面的错误还存在--__--