I had the same error for a newly registered user.
def attempt_login(self, email, password): user = authenticate(username=email, password=password) login(self.request, user) return user
I registered in the database and the user was created after registration, but this error was still there.
I realized that the user login (email) was longer than 30 characters, and the form field was not checked. The username was truncated in the database, and therefore authentication was called for a nonexistent login.
254 - The character is the recommended length of the email field.
Solution: emailfield-max_length-r11092.patch
source share