Django allauth 断言错误

Django allauth AssertionError

尝试添加

时收到的问候 AssertionError

ACCOUNT_USERNAME_VALIDATORS = ('allauth.socialaccount.providers.battlenet.validators.BattletagUsernameValidator',)

当它是一个列表时也会发生同样的情况,如果我只添加 str ,我会收到错误消息 ACCOUNT_USERNAME_VALIDATORS must be a list

其他授权配置

AUTHENTICATION_BACKENDS = (
     # Needed to login by username in Django admin, regardless of `allauth`
    'django.contrib.auth.backends.ModelBackend',
    # `allauth` specific authentication methods, such as login by e-mail
    'allauth.account.auth_backends.AuthenticationBackend',
)
ACCOUNT_AUTHENTICATION_METHOD = "username_email"

ACCOUNT_EMAIL_REQUIRED=True
ACCOUNT_EMAIL_VERIFICATION = "optional"
ACCOUNT_LOGIN_ATTEMPTS_LIMIT =5
ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT =300
ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS = 5
LOGIN_REDIRECT_URL = "/"
ACCOUNT_USERNAME_MIN_LENGTH = 3

在没有更多上下文的情况下,您的问题可能与以下方面有关: https://github.com/pennersr/django-allauth/pull/1648

链接问题中提出的解决方案是:

# Use a string in settings
ACCOUNT_USERNAME_VALIDATORS = 'foobar.validators.username_validators'

# Return a list in the validators
def username_validators():
    return [
        socialaccount.providers.battlenet.validators.BattletagUsernameValidator,
    ]