[Answer]-Is it posible in Django to authenticate a user with 2 fields?

1๐Ÿ‘

I think at the root all you have to do is create your own authentiaction backened, and register it.

class YourBackend(object)
  def authenticate(self, username=None, your_other_field=None):
    # get user based on username AND other field
    return user instance or None

Then all you have to do is register in AUTHENTICATION_BACKEND. Remember:

The order of AUTHENTICATION_BACKENDS matters, so if the same username
and password is valid in multiple backends, Django will stop
processing at the first positive match.

๐Ÿ‘คdm03514

Leave a comment