0

I would like to have different types of Users in Django (say Driver and Passenger). So I want both email (with password for Driver) and phone number (with password + OTP for Passenger) authentication.

So I have created custom authentication back end and that is fine.

But in my User model, I have to add both email and phone. Is there any way that could create different kind of two users, one user model (Driver) store email & password and other one (Passenger) stores phone, OTP and password ?

Uzama Zaid
  • 374
  • 3
  • 10

1 Answers1

0

The simplest way is to create a form with all of the above fields and POST the data to the backend. When the view receives the data, you can get the specifics fields from the data and save them to the respective models using model instances. The other way is if you are using a custom signup form, you can use django_signals to save the data in the respective models using the post_save or pre_save method.

abdadeel
  • 446
  • 5
  • 8