Cha*_*g_p 5 django django-views django-rest-framework django-allauth django-rest-auth
https://django-rest-auth.readthedocs.io/en/latest/installation.html这里是关于 django-rest-auth 中社交登录的官方文档。他们说让 LoginView(GithubLogin, FacebookLogin, etc..) 像这样继承 SocialLoginView 的方法。
from allauth.socialaccount.providers.github.views import GitHubOAuth2Adapter
from allauth.socialaccount.providers.oauth2.client import OAuth2Client
from rest_auth.registration.views import SocialLoginView
class GithubLogin(SocialLoginView):
adapter_class = GitHubOAuth2Adapter
callback_url = CALLBACK_URL_YOU_SET_ON_GITHUB
client_class = OAuth2Client
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用 as.view() 访问 url 时,他们总是说
{
"non_field_errors": [
"View is not defined, pass it as a context variable"
]
}
Run Code Online (Sandbox Code Playgroud)
我尽力了。我已经痛苦了几天了。请问有人救了我的命..有什么问题吗?我已经搜索了很多,但对我来说没有任何好的答案。
所以我做了一些挖掘,发现了问题。
django-rest-auth 包不再维护,因此不支持现代版本的 django Rest 框架。在撰写本文时,DRF 3.10.3 版本已被验证可以正常工作,而我可以验证 3.12.1 版本(可能还有更高版本)不能正常工作。
看起来该项目已经分叉到dj-rest-auth并在那里获得进一步的支持。我建议迁移到该包。
您可以在此处阅读有关停止维护并分叉到新存储库的决定的更多信息。
| 归档时间: |
|
| 查看次数: |
874 次 |
| 最近记录: |