1

从 uWSGI 启动 Django 时出现此错误,但不知道出了什么问题:

...
File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 160, in _fetch
    app = import_module(appname)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
ImportError: No module named pocdebug_toolbar

蟒蛇2.7.3;Django==1.4.3;Ubuntu 12.04.2 LTS

Here is the full traceback:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 241, in __call__
    response = self.get_response(request)  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 179, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 221, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)  File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 66, in technical_500_response
    html = reporter.get_traceback_html()  File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 287, in get_traceback_html
    return t.render(c)
  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 140, in render
    return self._render(context)
  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 134, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 823, in render
    bit = self.render_node(node, context)
  File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 74, in render_node
    return node.render(context)
  File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 84, in render
    output = self.filter_expression.resolve(context)
  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 599, in resolve
    new_obj = func(obj, *arg_vals)
  File "/usr/local/lib/python2.7/dist-packages/django/template/defaultfilters.py", line 718, in date
    return format(value, arg)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 310, in format
    return df.format(format_string)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 33, in format
    pieces.append(force_unicode(getattr(self, piece)()))
  File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 214, in r
    return self.format('D, j M Y H:i:s O')
  File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 33, in format
    pieces.append(force_unicode(getattr(self, piece)()))
  File "/usr/local/lib/python2.7/dist-packages/django/utils/encoding.py", line 71, in force_unicode
    s = unicode(s)  File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 121, in __unicode_cast
    return func(*self.__args, **self.__kw)  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py", line 86, in ugettext
    return _trans.ugettext(message)  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 278, in ugettext
    return do_translate(message, 'ugettext')  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 268, in do_translate
    _default = translation(settings.LANGUAGE_CODE)  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 183, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 160, in _fetch
    app = import_module(appname)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
ImportError: No module named pocdebug_toolbar
4

1 回答 1

1

解决了。我忘记了settings.py INSTALLED_APPS元组中我的应用程序之间的逗号,所以它将两个字符串“poc”和“debug_toolbar”连接成“pocdebug_toolbar”。

INSTALLED_APPS = (
   ...
   'poc'  # <== missing comma here
   'debug_toolbar'
   )
于 2013-04-19T16:52:45.900 回答