def get_username_field(): try: username_field = User.USERNAME_FIELD except AttributeError: username_field = 'username' return username_field