我想创建一个使用django admin的应用程序,但允许通过谷歌(我的公司谷歌帐户)登录来代替django默认ModelAdmin。集成与Django admin一起使用的python-social-auth(social-app-django)
目前,它看起来像social-app-django(谷歌)是的路要走,但是已经安装并设置一个项目后,这是我不清楚我怎么才能让Django管理登录使用social-app-django认证。我试图配置我的项目,如http://python-social-auth.readthedocs.io/en/latest/configuration/django.html所述,但不清楚如何将其与django管理员集成。
我发现这个snippit(这似乎外的日期),并补充道,却得到了一个404,当我尝试转到/admin/
:找不到
页(404)请求方法: GET请求 URL:http://127.0.0.1:8000/accounts/login/?next=/admin/login/%3Fnext%3D/admin/ 使用在telos.urls中定义的URLconf,Django按以下顺序尝试了这些URL 模式:^ login /(?P [^ /] +)/ $ [name ='begin'] ^完成/(?P [^ /] +)/ $ [name ='complete'] ^ disconnect /(?P [^ /] +)/ $ [name ='disconnect'] ^ di sconnect /(?P [^ /] +)/(?P [^ /] +)/ $ [name ='disconnect_individual']^admin /当前路径, accounts/login /,这些。
如果我删除的这段,/admin/
会重定向到/admin/login/
及登录尝试返回错误文本:
请输入员工帐户正确的用户名和密码。 请注意,这两个字段可能区分大小写。
除了configuration,我已经添加了以下到我的settings.py
:
项目/ models.py(MYUSER)
from django.contrib.auth.models import AbstractUser
class MyUser(AbstractUser):
pass
settings.py
# for identification of SOCIAL_AUTH_USER
# http://python-social-auth.readthedocs.io/en/latest/configuration/settings.html#user-model
SOCIAL_AUTH_USER_MODEL = 'projects.MyUser'
AUTH_USER_MODEL = 'projects.MyUser' # not sure if this is needed
Ca ñ任何人指导我如何设置我的项目,让我登录到Django管理通过social-app-django(谷歌)?
必须弄清楚如何覆盖模板等等,但得到它的工作。谢谢! – monkut