I received the following django error
File "./project/auth_backend.py", line 31, in authenticate
user.save()
...
IntegrityError: (1062, "Duplicate entry 'user_name' for key 'username'")
The said file contains the following code (which is based on https://docs.djangoproject.com/en/1.8/topics/auth/customizing/#writing-an-authentication-backend)
try:
user = User.objects.get(username=username)
except User.DoesNotExist:
user = User(username=username, password=password)
...
user.save()
It seems that somehow it raised User.DoesNotExist even when it actually does exist. My database is MySQL.
I've seen others with a similar problem but unlike them, I'm not using any database caching.