I have a form that only allow users to login via username . I decided to only allow user to login via email instead of username.
First, this is not a duplication of any
Looks like you are testing against 2 different fields. You look for the user against email
if User.objects.filter(email=user).exists():
but then validate against username
user = authenticate(username=user, password=password)
If you are using the email address the auth line should be
user = authenticate(email=user, password=password)