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.
精彩评论