【问题标题】:django.core.exceptions.ImproperlyConfigured: Enable 'django.contrib.auth.context_processors.auth'django.core.exceptions.ImproperlyConfigured:启用 'django.contrib.auth.context_processors.auth'
【发布时间】:2016-05-02 12:46:48
【问题描述】:

我开始了一个新项目并得到:

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

我遵循 1.9 的 django 文档:

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

可能是什么问题(它希望我如何配置)?谢谢

【问题讨论】:

标签: python django django-settings django-1.9


【解决方案1】:

您需要将其添加到OPTIONS 中的context_processors 列表中:

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",
            ]
        }
    }
]

【讨论】:

  • 事实上,确实如此。这是解释该部分的link
猜你喜欢
  • 2014-11-24
  • 2015-05-25
  • 2016-07-16
  • 1970-01-01
  • 1970-01-01
  • 2022-11-02
  • 2015-07-22
  • 2018-05-17
  • 1970-01-01
相关资源
最近更新 更多