升级到 1.8.1 后 Django 管理中断

2024-06-19

我从 1.7.3 升级到 1.8.1,但我的管理员无法工作,并且站点无法加载,因为它在解析路径时失败。

例外:

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

这是堆栈跟踪:

Environment:


Request Method: GET
Request URL: 

Django Version: 1.8.1
Python Version: 2.7.8
Installed Applications:
('django.contrib.admin',
 ..)
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 ..)


Traceback:
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  119.                 resolver_match = resolver.resolve(request.path_info)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/urlresolvers.py" in resolve
  366.             for pattern in self.url_patterns:
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/urlresolvers.py" in url_patterns
  402.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/urlresolvers.py" in urlconf_module
  396.             self._urlconf_module = import_module(self.urlconf_name)
File "/app/.heroku/python/lib/python2.7/importlib/__init__.py" in import_module
  37.     __import__(name)
File "/app/appname/urls.py" in <module>
  72.     url(r'^tarantino/', include(admin.site.urls)),
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/sites.py" in urls
  291.         return self.get_urls(), 'admin', self.name
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/sites.py" in get_urls
  250.             self.check_dependencies()
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/sites.py" in check_dependencies
  194.                     "Enable 'django.contrib.auth.context_processors.auth' "

Exception Type: ImproperlyConfigured at /
Exception Value: Enable 'django.contrib.auth.context_processors.auth' in your TEMPLATES setting in order to use the admin application.

我有'django.contrib.auth.context_processors.auth in my TEMPLATE_CONTEXT_PROCESSORS已经很不确定为什么现在会发生这种情况?


The TEMPLATE_CONTEXT_PROCESSORS被删除,并替换为TEMPLATESDjango 1.8 中的设置。

您必须根据此修改您的设置guide https://docs.djangoproject.com/en/1.8/ref/templates/upgrading/,通过删除旧的TEMPLATE_CONTEXT_PROCESSORS and TEMPLATE_DIRS设置:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

升级到 1.8.1 后 Django 管理中断 的相关文章

随机推荐