3
votes

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: [email protected]

password: mypassword

email: [email protected]

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 :)

1

1 Answers

2
votes

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.