Login with email address, mobile number or username.

34 views
Skip to first unread message

lakshitha kumara

unread,
Apr 19, 2018, 7:18:02 AM4/19/18
to Django users
Hello Guys ,

what is the best way to implement Login with email address, mobile number or username. all those field save as a different field in user table. user can login with any criteria that user provided to registered. its look like how instagram.com does it. i need know what is the best way to implement this. Username field cant include '@' sign and username should be letter, number and '_' .

Thanks

Andy

unread,
Apr 19, 2018, 10:42:32 AM4/19/18
to Django users
Firt of all you should start with you own user model because changing it afterwards is not that easy like stated in the docs.
From there you can change the username restrictions to your liking and implement the cell_phone field.

Then implement you own version of ModelBackend which is also checking email and cell phone.
In case you just want to allow email, you can also switch to that with just changing a setting: https://docs.djangoproject.com/en/2.0/topics/auth/customizing/#django.contrib.auth.models.CustomUser.USERNAME_FIELD
Reply all
Reply to author
Forward
0 new messages