django.core.exceptions.ImproperlyConfigured: Enable 'django.contrib.auth.context_processors.auth'

南笙酒味 提交于 2019-12-10 14:48:31

问题


I started a new project and am getting:

django.core.exceptions.ImproperlyConfigured: Enable 'django.contrib.auth.context_processors.auth' in your TEMPLATES setting in order to use the admin application.

I followed the django docs for 1.9:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
    }
]

What could be the issue (how does it want me configure)? Thank you


回答1:


You need to add it into context_processors list in the OPTIONS:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                "django.contrib.auth.context_processors.auth",
            ]
        }
    }
]


来源:https://stackoverflow.com/questions/35005647/django-core-exceptions-improperlyconfigured-enable-django-contrib-auth-context

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!