4

我有一个自定义用户模型,我自己的身份验证到位。但尽管如此,我无法登录到 Django 管理员。该页面出现,但它不接受我的凭据(这是正确的)。我已将django.contrib.auth.backends.ModelBackend我的自定义身份验证后端包含在AUTHENTICATION_BACKENDS. 和is_staffis_admin在我签入 shell 时设置。

我错过了一些明显的东西吗?

AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend',
                            'final.backends.CustomBackend',)


AUTH_USER_MODEL = 'final.MyUser'

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)


INSTALLED_APPS = (
'rest_framework.authtoken',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'final',
'rest_framework',
)

REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
    'final.authentication.ExpiringTokenAuthentication',
)
}

请忽略可怜的缩进。他们在复制粘贴大屠杀中迷路了。

4

0 回答 0