Fixes #461 by checking for the USERNAME_FIELD attribute on the User model and defaulting to 'username' if the attribute is not defined or has a None value.