有人知道让 django-registration 使用电子邮件作为用户名的好方法吗?
我计划在我的网站上进行电子邮件注册激活,该网站很快就会推出。我刚刚开始研究 django-registration,并且对 django 上提供的其他电子邮件注册激活系统持开放态度。
我唯一的要求是,对于我的网站,我实际上不使用用户名。相反,用户使用他们的电子邮件和密码登录。我想获得专家的意见,如何为此目的干净和安全修改 django-registration。
如果有更简单且可扩展的解决方案,请随时在此发布。
I am planning to do email-registration-activation on my site which will be launched very soon. I have just started looking at django-registration and I am open to other email-registration-activation system available on django.
My only requirement is that for my site, I don't actually use usernames. Rather, user logs in with their emails and passwords. I want to get an expert's opinion how to modify django-registration cleanly and safely for this purpose.
If there are easier solutions which are scalable, feel free to post up here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们将 django-registration 与自定义后端一起使用,其中我们覆盖(或定义)了注册表单的 clean 方法:
还有其他方法:
请注意,默认情况下,用户名只能30 个字符长。您也需要对此进行破解:
We used
django-registration
with a custom backend, where we overwrote (or defined) theclean
method of the registration form:There are other ways:
Note that by default, usernames can be only 30 chars long. You'll need a hack for that, too:
从
Django 1.5
开始,现在可以自定义 auth.User 并将电子邮件地址作为用户名。Since
Django 1.5
now it possible to have custom auth.User and make email address as username.