I’m using the UserModel and the UserCreationForm in Django. However, instead of requiring a username, I want to use the customer’s email as the login information (i.e. completely bypass / ignore the username field).
- How do I go about making the username field to be optional in the User Model
- How do I turn email into the customer’s “username”? In turn, how do I make this email field to be required then?
1.) Just make the username field optional in your form and to the model pass the email as the username, after stripping out ‘@’ from the email.
2) Create a custom authentication backend (this will accept either the username or email):
chage your settings accordingly :