我有同样的问题,但我发现@alix 的回答很有帮助。我忘记添加了is_active=True on create_superuser()
def create_staffuser(self, email, first_name=None, last_name=None, user_role=None, password=None):
user = self.create_user(
email,
first_name=first_name,
last_name=last_name,
user_role=user_role,
password=password,
is_staff=True,
is_active=True
)
return user
所以基本上你需要专注于 is_active 并检查你的
# changes the in-build User model to ours (Custom)
AUTH_USER_MODEL = 'accounts.User'
AUTHENTICATION_BACKENDS = (
# Needed to login by custom User model, regardless of `allauth`
"django.contrib.auth.backends.ModelBackend",
# `allauth` specific authentication methods, such as login by e-mail
"allauth.account.auth_backends.AuthenticationBackend",
)