django 和 mod_wsgi:TemplateSyntaxError - 列表索引超出范围
哎呀。尝试使用 mod_wsgi 在 Apache 上运行我的 Django 应用程序。遇到这么多错误。这是我无法弄清楚的最新一个:
[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 作为解决方案,但这对我不起作用。
谢谢。
Yikes. Trying to run my Django app on Apache using mod_wsgi. Running into so many error. Here's the latest one that I cannot figure out:
[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
One thing that's weird is I don't know why PycharmProjects/mg
is even mentioned. My project used to live under the folder 'mg' but I've changed it to 'ml' quite some time ago. I have no trouble in dev server of course. I read on another SO thread about changing mod_wsgi to Daemon as a solution, but that did not work for me.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为错误的 wsgi 文件就是原因。检查您的 apache 站点文件。
I think wrong wsgi file is the reason. Check your apache site file.