1

我有点卡住了。

我正在我的 Mac 中配置一个项目以使用它(我过去曾在同一台计算机上处​​理它),但必须对其进行格式化。

尝试python runserver时它工作正常,但是当尝试在浏览器中加载它时,我得到了这个:

在此处输入图像描述

我在终端得到这个:

$ python manage.py runserver
Validating models...

0 errors found
Django version 1.4.2, using settings '****.settings'
Development server is running at http:// 127 .0.0.1:8000 /
Quit the server with CONTROL-C.
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/Library/Python/2.7/site-packages/django/core/handlers/wsgi.py", line 219, in __call__
    self.load_middleware()
  File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 47, in load_middleware
    raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
ImproperlyConfigured: Error importing middleware quizzer.views: "cannot import name PMMail"
[12/Sep/2014 11:31:53] "GET / HTTP/1.1" 500 59
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/Library/Python/2.7/site-packages/django/core/handlers/wsgi.py", line 219, in __call__
    self.load_middleware()
  File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 47, in load_middleware
    raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
ImproperlyConfigured: Error importing middleware quizzer.views: "cannot import name PMMail"
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/Library/Python/2.7/site-packages/django/core/handlers/wsgi.py", line 219, in __call__
    self.load_middleware()
  File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 47, in load_middleware
    raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
ImproperlyConfigured: Error importing middleware quizzer.views: "cannot import name PMMail"
[12/Sep/2014 11:35:16] "GET / HTTP/1.1" 500 59
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/Library/Python/2.7/site-packages/django/core/handlers/wsgi.py", line 219, in __call__
    self.load_middleware()
  File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 47, in load_middleware
    raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
ImproperlyConfigured: Error importing middleware quizzer.views: "cannot import name PMMail"

编辑

这是我来自 settings.py 的中间件类

MIDDLEWARE_CLASSES = (
'debug_toolbar.middleware.DebugToolbarMiddleware',
'quizzer.views.FacebookMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'quizzer.middleware.SetGroupMiddleware',
'quizzer.django-crossdomainxhr-middleware.XsSharing',

# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
4

1 回答 1

3

也许您还没有安装PMMail库。

使用 pip 运行安装pip install git+https://github.com/themartorana/python-postmark.git

于 2014-09-12T14:27:40.823 回答