Managed to find the problem with the login - it was somewhere within one of my backend classes. Removing this step from the login process now means I can login, although can now require case sensitive usernames (rather than allowing case insensitive as I'd prefer).
Here's the code I have for that if you have any suggestions, but it's not too vital now because I can get logins working (and I can probably figure out another solution to this eventually)!
from django.contrib.auth import get_user_model
from django.contrib.auth.backends import ModelBackend
class CaseInsensitiveModelBackend(ModelBackend):
def authenticate(self, request, username=None, password=None, **kwargs):
UserModel = get_user_model()
if username is None:
username = kwargs.get(UserModel.USERNAME_FIELD)
if username is None or password is None:
return
try:
user = UserModel._default_manager.get(username__iexact==username)
except UserModel.DoesNotExist:
# Run the default password hasher once to reduce the timing
# difference between an existing and a non-existing user (#20760).
UserModel().set_password(password)
return
if user.check_password(password) and self.user_can_authenticate(user):
return user