Django错误 - 没有名为context_processors的模块

时间:2016-01-16 12:13:03

标签: python django

就在今天,我从Django 1.7升级到1.9.1,我已经清除了所有其他警告但是我遇到了一个阻止我继续前进的警告。如果有人对导致此错误的原因有任何想法,请告诉我您是否需要查看其他任何代码。谢谢!

完全追溯 -

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/

Django Version: 1.9.1
Python Version: 2.7.10
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'main',
 'listings',
 'profiles',
 'allauth',
 'allauth.account',
 'allauth.socialaccount')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')



Traceback:

File "C:\Python27\Lib\site-packages\django\core\handlers\base.py" in get_response
  149.                     response = self.process_exception_by_middleware(e, request)

File "C:\Python27\Lib\site-packages\django\core\handlers\base.py" in get_response
  147.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "D:\Other folders\Desktop\Student Job Search\code\opus_jobs_project\main\views.py" in index
  8.     return render(request, 'index.html', context_dict)

File "C:\Python27\Lib\site-packages\django\shortcuts.py" in render
  67.             template_name, context, request=request, using=using)

File "C:\Python27\Lib\site-packages\django\template\loader.py" in render_to_string
  97.         return template.render(context, request)

File "C:\Python27\Lib\site-packages\django\template\backends\django.py" in render
  95.             return self.template.render(context)

File "C:\Python27\Lib\site-packages\django\template\base.py" in render
  204.                 with context.bind_template(self):

File "C:\Python27\lib\contextlib.py" in __enter__
  17.             return self.gen.next()

File "C:\Python27\Lib\site-packages\django\template\context.py" in bind_template
  256.         processors = (template.engine.template_context_processors +

File "C:\Python27\Lib\site-packages\django\utils\functional.py" in __get__
  33.         res = instance.__dict__[self.name] = self.func(instance)

File "C:\Python27\Lib\site-packages\django\template\engine.py" in template_context_processors
  105.         return tuple(import_string(path) for path in context_processors)

File "C:\Python27\Lib\site-packages\django\template\engine.py" in <genexpr>
  105.         return tuple(import_string(path) for path in context_processors)

File "C:\Python27\Lib\site-packages\django\utils\module_loading.py" in import_string
  20.     module = import_module(module_path)

File "C:\Python27\lib\importlib\__init__.py" in import_module
  37.     __import__(name)

Exception Type: ImportError at /
Exception Value: No module named context_processors

模板设置 - (我感觉错误可能在这里或至少这可能链接到它)

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            TEMPLATE_PATH
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'allauth.account.context_processors.account',
                'allauth.socialaccount.context_processors.socialaccount',
                'django.contrib.auth.context_processors.auth',
                'django.template.context_processors.debug',
                'django.template.context_processors.i18n',
                'django.template.context_processors.media',
                'django.template.context_processors.static',
                'django.template.context_processors.tz',
                'django.contrib.messages.context_processors.messages',
                'django.template.context_processors.request',
            ],

        },
    },
]

1 个答案:

答案 0 :(得分:2)

正如您在评论中提到的,导致问题的是allauth上下文处理器,我查找了它们并且不再需要它们

来自allauth changelog

  

不再使用模板上下文处理器。 allauth.account的上下文处理器已经为空,allauth.socialaccount的上下文处理器已转换为{%get_providers%}模板标记。