Login with email or phone not username

470 views
Skip to first unread message

Achyut Pandey

unread,
Jan 5, 2019, 9:07:50 PM1/5/19
to django...@googlegroups.com

Hello guys i want to allow user to register and login with their email or phone number instead of username . How can i do that i am extending user model with abstractuser.

Andréas Kühne

unread,
Jan 6, 2019, 9:17:50 AM1/6/19
to django...@googlegroups.com
Hi,

You can find the information you need here: 

Change the USERNAME_FIELD and you are good to go!

Regards,

Andréas


Den sön 6 jan. 2019 kl 03:07 skrev Achyut Pandey <anjan.sa...@gmail.com>:

Hello guys i want to allow user to register and login with their email or phone number instead of username . How can i do that i am extending user model with abstractuser.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/A50B7F88-AAE8-4A9C-AEF9-A27649F3D643%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Achyut Pandey

unread,
Jan 6, 2019, 9:41:07 AM1/6/19
to django...@googlegroups.com
Thanks for your reply bro.

Sent from my iPhone

kaushik kumar roy

unread,
Jan 6, 2019, 12:56:09 PM1/6/19
to django...@googlegroups.com
Hi,
i think you can add a if condition in your view.py , stating if the username matches to a regular expression for mobile or email.
if the regular expression matches the email you can go ahead calling the user authenticate method and pass the email. But if the regular expression matches for mobile than try to write another function to query using mobile number. You need to have a mobile number field in your model. 
I am not sure how we can query the user model with another field and password to authenticate a user. Anyways if you find something better do update us in this thread.

thanks and regards
Kaushik Kr Roy
 

On Sun, 6 Jan 2019 at 07:39, Achyut Pandey <anjan.sa...@gmail.com> wrote:
Boxbe This message is eligible for Automatic Cleanup! (anjan.sa...@gmail.com) Add cleanup rule | More info

Hello guys i want to allow user to register and login with their email or phone number instead of username . How can i do that i am extending user model with abstractuser.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/A50B7F88-AAE8-4A9C-AEF9-A27649F3D643%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


--
----------------------
Kauhsik Kr Roy

Manas Nikam

unread,
Jan 7, 2019, 5:13:31 AM1/7/19
to Django users
Add AccountKit integration https://www.accountkit.com/ into into app and add the authentication backend for the same

Achyut Pandey

unread,
Jan 20, 2019, 9:25:36 AM1/20/19
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages