[Fixed]-Django not authenticating using custom User model

1👍

Do not use this code:

    email = request.POST.get('email')
    password = hashlib.md5(request.POST.get('password')).hexdigest()

    #db query to check if email and password combination exist
    user = Users.objects.get(email=email,password=password)

Instead use the authenticate method. It returns a User

user = authenticate(email=email, password=password)

This assumes that you have an appropriate auth backend setup.

Leave a comment