简体   繁体   English

接受用户名或电子邮件以使用django-allauth登录

[英]Accept username OR email for logging in with django-allauth

I see django-allauth supports forcing users to login using their email address, and doesn't ask them for a username when signing up (instead generating one automatically from the email address) - https://stackoverflow.com/a/19683532/221001 我看到Django的allauth支持强制用户使用其电子邮件地址登录,并且不要求他们输入用户名注册时(而不是自动从电子邮件地址生成一个) - https://stackoverflow.com/a/19683532/ 221001

Is it possible to have a user sign up, entering an email address and username manually, and then allow them to sign in using either? 是否可以让用户注册,手动输入电子邮件地址和用户名,然后允许他们使用任一登录? (eg there are two fields on the Login page: "username or email" and "password") (例如,登录页面上有两个字段:“用户名或电子邮件”和“密码”)

As Yogesh posted above, the username_email value for ACCOUNT_AUTHENTICATION_METHOD does the job. 如Yogesh上面所述, ACCOUNT_AUTHENTICATION_METHODusername_email值完成了该工作。

http://django-allauth.readthedocs.org/en/latest/configuration.html http://django-allauth.readthedocs.org/en/latest/configuration.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM