[Answer]-Django Email As User Name

1👍

I actually end up using django-authtools

👤Waqas

0👍

Get the email and password using form

email = form.cleaned_data['email']
password = form.cleaned_data['password']

If the given email matches with exiting record.

try:
    user = User.objects.get(email=email)
    if user.check_password(password):
        username = user.username
        user = authenticate(username=username, password=password)
        login(request, user)
        messages.success(request, "Welcome {}".format(email))
    else:
        messages.error(request, "Password not match for  {}".format(email))
except User.DoesNotExist:
    pass

Leave a comment