enter code here
I put my project on server and use uwsgi attempt to start.
like.. uwsgi --http :8000 --module myDjangoProject.wsgi
it can run, but when i come to my site,append an error....
Internal Server Error: /
Traceback (most recent call last):
File "/var/www/myDjangoProject/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/var/www/myDjangoProject/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/var/www/myDjangoProject/lib/python3.6/site-packages/django/core/handlers/base.py", line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "./apps/news/views.py", line 27, in index
File "/var/www/myDjangoProject/lib/python3.6/site-packages/django/shortcuts.py", line 36, in render
content = loader.render_to_string(template_name, context, request, using=using)
File "/var/www/myDjangoProject/lib/python3.6/site-packages/django/template/loader.py", line 62, in render_to_string
return template.render(context, request)
File "/var/www/myDjangoProject/lib/python3.6/site-packages/django/template/backends/django.py", line 61, in render
return self.template.render(context)
File "/var/www/myDjangoProject/lib/python3.6/site-packages/django/template/base.py", line 169, in render
with context.bind_template(self):
File "/usr/lib/python3.6/contextlib.py", line 81, in __enter__
return next(self.gen)
File "/var/www/myDjangoProject/lib/python3.6/site-packages/debug_toolbar/panels/templates/panel.py", line 41, in _request_context_bind_template
processors = template.engine.template_context_processors + self._processors
File "/var/www/myDjangoProject/lib/python3.6/site-packages/django/utils/functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/var/www/myDjangoProject/lib/python3.6/site-packages/django/template/engine.py", line 85, in template_context_processors
return tuple(import_string(path) for path in context_processors)
File "/var/www/myDjangoProject/lib/python3.6/site-packages/django/template/engine.py", line 85, in <genexpr>
return tuple(import_string(path) for path in context_processors)
File "/var/www/myDjangoProject/lib/python3.6/site-packages/django/utils/module_loading.py", line 17, in import_string
module = import_module(module_path)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'apps.cms.context_processors'
i think there is something wrong with my setting.py where i design my own context_processors in my project
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'front', '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',
*'apps.cms.context_processors.user_profile_front',
'apps.cms.context_processors.leader_assignments_prompt',
'apps.news.context_processors.hot_article',*
],
'builtins':[
'django.templatetags.static',
],
'libraries': {
'news_filters': 'apps.news.templatetags.news_filters',
'cms_filters': 'apps.cms.templatetags.cms_filters',
},
},
},
my project can run with manage.py runserver,when i delete this three line and use uwsgi to start,the error disappear,but my designed context_processors lose efficacy..how can i resolve it....
'apps.cms.context_processors.user_profile_front',
'apps.cms.context_processors.leader_assignments_prompt',
'apps.news.context_processors.hot_article'
I resolved it by add --pythonpath /opt/myDjangoProject/ in uwsgi, where is my project's absolutepath