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 sofisticated solution ?
Thanks 🙂
Probably not a good idea to circumvent the expected regex validation on
usernamewhich isr'^\w+$'(so no@or., obviously). Also, there’s a 30 character limit onusername, 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.