#django #mod-wsgi
#django #мод-wsgi
Вопрос:
Ого. Пытаюсь запустить мое приложение Django на Apache, используя mod_wsgi. Сталкиваюсь с таким количеством ошибок. Вот последний, который я не могу понять:
[Fri Apr 22 23:21:31 2011] [error] [client ::1] mod_wsgi (pid=23999): Exception occurred processing WSGI script '/Users/kevin/PycharmProjects/ml/apache/django.wsgi'.
[Fri Apr 22 23:21:31 2011] [error] [client ::1] Traceback (most recent call last):
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/core/handlers/wsgi.py", line 273, in __call__
[Fri Apr 22 23:21:31 2011] [error] [client ::1] response = self.get_response(request)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/core/handlers/base.py", line 169, in get_response
[Fri Apr 22 23:21:31 2011] [error] [client ::1] response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/core/handlers/base.py", line 203, in handle_uncaught_exception
[Fri Apr 22 23:21:31 2011] [error] [client ::1] return debug.technical_500_response(request, *exc_info)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/views/debug.py", line 59, in technical_500_response
[Fri Apr 22 23:21:31 2011] [error] [client ::1] html = reporter.get_traceback_html()
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/views/debug.py", line 151, in get_traceback_html
[Fri Apr 22 23:21:31 2011] [error] [client ::1] return t.render(c)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/template/base.py", line 123, in render
[Fri Apr 22 23:21:31 2011] [error] [client ::1] return self._render(context)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/template/base.py", line 117, in _render
[Fri Apr 22 23:21:31 2011] [error] [client ::1] return self.nodelist.render(context)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/template/base.py", line 744, in render
[Fri Apr 22 23:21:31 2011] [error] [client ::1] bits.append(self.render_node(node, context))
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/template/debug.py", line 73, in render_node
[Fri Apr 22 23:21:31 2011] [error] [client ::1] result = node.render(context)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/template/debug.py", line 90, in render
[Fri Apr 22 23:21:31 2011] [error] [client ::1] output = self.filter_expression.resolve(context)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/template/base.py", line 536, in resolve
[Fri Apr 22 23:21:31 2011] [error] [client ::1] new_obj = func(obj, *arg_vals)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/template/defaultfilters.py", line 695, in date
[Fri Apr 22 23:21:31 2011] [error] [client ::1] return format(value, arg)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/utils/dateformat.py", line 285, in format
[Fri Apr 22 23:21:31 2011] [error] [client ::1] return df.format(format_string)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/utils/dateformat.py", line 30, in format
[Fri Apr 22 23:21:31 2011] [error] [client ::1] pieces.append(force_unicode(getattr(self, piece)()))
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/utils/dateformat.py", line 191, in r
[Fri Apr 22 23:21:31 2011] [error] [client ::1] return self.format('D, j M Y H:i:s O')
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/utils/dateformat.py", line 30, in format
[Fri Apr 22 23:21:31 2011] [error] [client ::1] pieces.append(force_unicode(getattr(self, piece)()))
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/utils/encoding.py", line 71, in force_unicode
[Fri Apr 22 23:21:31 2011] [error] [client ::1] s = unicode(s)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/utils/functional.py", line 206, in __unicode_cast
[Fri Apr 22 23:21:31 2011] [error] [client ::1] return self.__func(*self.__args, **self.__kw)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/utils/translation/__init__.py", line 81, in ugettext
[Fri Apr 22 23:21:31 2011] [error] [client ::1] return _trans.ugettext(message)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/utils/translation/trans_real.py", line 286, in ugettext
[Fri Apr 22 23:21:31 2011] [error] [client ::1] return do_translate(message, 'ugettext')
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/utils/translation/trans_real.py", line 276, in do_translate
[Fri Apr 22 23:21:31 2011] [error] [client ::1] _default = translation(settings.LANGUAGE_CODE)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/utils/translation/trans_real.py", line 185, in translation
[Fri Apr 22 23:21:31 2011] [error] [client ::1] default_translation = _fetch(settings.LANGUAGE_CODE)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/utils/translation/trans_real.py", line 162, in _fetch
[Fri Apr 22 23:21:31 2011] [error] [client ::1] app = import_module(appname)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/utils/importlib.py", line 35, in import_module
[Fri Apr 22 23:21:31 2011] [error] [client ::1] __import__(name)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/haystack/__init__.py", line 154, in <module>
[Fri Apr 22 23:21:31 2011] [error] [client ::1] handle_registrations()
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/haystack/__init__.py", line 151, in handle_registrations
[Fri Apr 22 23:21:31 2011] [error] [client ::1] search_sites_conf = importlib.import_module(settings.HAYSTACK_SITECONF)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Library/Python/2.6/site-packages/django/utils/importlib.py", line 35, in import_module
[Fri Apr 22 23:21:31 2011] [error] [client ::1] __import__(name)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Users/kevin/PycharmProjects/mg/../mg/search_sites.py", line 1, in <module>
[Fri Apr 22 23:21:31 2011] [error] [client ::1] import haystack
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Users/kevin/PycharmProjects/mg/haystack/__init__.py", line 154, in <module>
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/Users/kevin/PycharmProjects/mg/haystack/__init__.py", line 143, in handle_registrations
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/inspect.py", line 955, in stack
[Fri Apr 22 23:21:31 2011] [error] [client ::1] return getouterframes(sys._getframe(1), context)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/inspect.py", line 936, in getouterframes
[Fri Apr 22 23:21:31 2011] [error] [client ::1] framelist.append((frame,) getframeinfo(frame, context))
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/inspect.py", line 911, in getframeinfo
[Fri Apr 22 23:21:31 2011] [error] [client ::1] lines, lnum = findsource(frame)
[Fri Apr 22 23:21:31 2011] [error] [client ::1] File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/inspect.py", line 573, in findsource
[Fri Apr 22 23:21:31 2011] [error] [client ::1] if pat.match(lines[lnum]): break
[Fri Apr 22 23:21:31 2011] [error] [client ::1] TemplateSyntaxError: Caught IndexError while rendering: list index out of range
Странно то, что я не знаю, почему PycharmProjects/mg
это даже упоминается. Раньше мой проект находился в папке ‘mg’, но я изменил его на ‘ml’ довольно давно. У меня, конечно, нет проблем с сервером разработки. Я читал в другой теме SO об изменении mod_wsgi на Daemon в качестве решения, но у меня это не сработало.
Спасибо.
Комментарии:
1. Хорошо, в итоге я удалил исходный код Haystack из своего каталога приложений Django, и теперь он работает нормально. Я думаю, я должен обсудить это с Haystack.
Ответ №1:
Я думаю, что причиной является неправильный файл wsgi. Проверьте файл вашего сайта apache.
WSGIScriptAlias /path/to/your/wsgi
Комментарии:
1. Спасибо за ваш ответ. Я не думаю, что проблема в этом.
/Users/kevin/PycharmProjects/ml/apache/django.wsgi
это правильный путь, как написано в первой строке ошибок, которые я вставил.