6

I'm trying to use two user models with different 'username' type each one.

First user type is an administrator who login in with username and password. Second, a customer who login with phone number and password. Only the customer has custom fields.

I tried customize the Django User model but it only allows one auth user model.

I am thinking use an authentication backend.

Administrator only will login in admin dashboard, while customer only login in application.

Edit.

Different problem from. My user types have different ways to login each other.

My solution: Use Django's user model for dashboard administrator only. Use a Customer model with custom authentication backend.

cristhiam
  • 496
  • 1
  • 4
  • 17

1 Answers1

6

First user type is an administrator who login in with username and password. Second, a customer who login with phone number and password. Only the customer has custom fields.

You don't want multiple user models (crazy and not really supported in Django anyway). You want multiple authentication backends.

Put a User model with a (nullable) phone number field. And add to your application an auth backend which uses phone number + password instead of username + password.

wim
  • 338,267
  • 99
  • 616
  • 750
  • 1
    Yup, I'm thinking about leave phone number null and code an authentication backend (but I also need use JWT with the phone number -_-) – cristhiam Apr 09 '19 at 01:23