间歇性使用nginx / uwsgi时没有名为context_processors的模块

时间:2019-01-03 00:34:15

标签: django nginx uwsgi

我有一个奇怪的django问题。我有一个应用程序,该应用程序部署在30个不同的站点上,其中一些站点使用apache和wsgi,有些站点使用nginx和uwsgi。仅在nginx / uwsgi站点上并且间歇地,用户将收到错误No module named context_processors

它可能发生在以前没有错误访问的页面上,并且刷新同一页面后,它会正常显示。它不会出现数月,然后一天会发生几次。

这是典型的回溯:

Internal Server Error: /
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py",
line 35, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py",
line 158, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py",
line 156, in _get_response
    response = response.render()
  File "/usr/local/lib/python3.5/dist-packages/django/template/response.py",
line 106, in render
    self.content = self.rendered_content
  File "/usr/local/lib/python3.5/dist-packages/django/template/response.py",
line 83, in rendered_content
    content = template.render(context, self._request)
  File "/usr/local/lib/python3.5/dist-packages/django/template/backends/django.py",
line 61, in render
    return self.template.render(context)
  File "/usr/local/lib/python3.5/dist-packages/django/template/base.py",
line 173, in render
    with context.bind_template(self):
  File "/usr/lib/python3.5/contextlib.py", line 59, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.5/dist-packages/django/template/context.py",
line 246, in bind_template
    processors = (template.engine.template_context_processors +
  File "/usr/local/lib/python3.5/dist-packages/django/utils/functional.py",
line 36, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.5/dist-packages/django/template/engine.py",
line 85, in template_context_processors
    return tuple(import_string(path) for path in context_processors)
  File "/usr/local/lib/python3.5/dist-packages/django/template/engine.py",
line 85, in <genexpr>
    return tuple(import_string(path) for path in context_processors)
  File "/usr/local/lib/python3.5/dist-packages/django/utils/module_loading.py",
line 17, in import_string
    module = import_module(module_path)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'ui.context_processors'

该文件确实存在并且可读:

-rw-rw-r-- 1 ubuntu ubuntu 1059 May  2  2018 ui/context_processors.py

这是我的模板设置:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, 'ui/templates'),
            os.path.join(BASE_DIR, 'app/dse/templates'),
            os.path.join(BASE_DIR, 'core/reports/templates'),
        ],
        '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',
                'context_processors.config',
                'ui.context_processors.navigation',
                'core.appmngr.context_processor',
            ],
        },
    },
]

正如我所说的那样,它是断断续续的。任何人都对它可能是什么和/或如何调试有任何想法?

0 个答案:

没有答案