开发者

Registration Form with only email + password

开发者 https://www.devze.com 2022-12-17 11:14 出处:网络
I want a Registration Form with only email + password. I am thinking to insert automatically email in username field. So, for eash user, I will have this:

I want a Registration Form with only email + password. I am thinking to insert automatically email in username field. So, for eash user, I will have this:

username: example@example.com

password: mypassword

email: example@example.com

Of course email + password will be used in login process.

Is it a good solution to having 2 fields with the same value ? Or is there a more sofistic开发者_如何转开发ated solution ?

Thanks :)


Probably not a good idea to circumvent the expected regex validation on username which is r'^\w+$' (so no @ or ., obviously). Also, there's a 30 character limit on username, so lots of email addresses won't fit.

You should write a custom auth backend that authenticates based on the actual email field - many people do this, so you can probably find samples on djangosnippets.

Two things to keep in mind - by default, the email field is non-unique. Also, you are almost definitely going to break the admin app, so you'll need to do some jiggery pokery if you want to use contrib.admin.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号