我启动了我的 virtualenv。然后通过python manage.py runserver
. 我最终访问了我的 django 站点并收到以下错误。
(venv)N$ python manage.py runserver
Validating models...
0 errors found
June 11, 2015 - 19:27:19
Django version 1.6.5, using settings 'nirsite.settings'
Starting development server 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/contrib/staticfiles/handlers.py", line 67, in __call__
return self.application(environ, start_response)
File "/Library/Python/2.7/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
self.load_middleware()
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 45, in load_middleware
mw_class = import_by_path(middleware_path)
File "/Library/Python/2.7/site-packages/django/utils/module_loading.py", line 31, in import_by_path
error_prefix, module_path, class_name))
ImproperlyConfigured: Module "django.contrib.auth.middleware" does not define a "SessionAuthenticationMiddleware" attribute/class
我已经检查了这个Stackoverflow,但我无法用这些答案中的任何一个来解决问题。看到 venv 设置正确,我认为摆脱任何中间件是没有意义的。
我可以根据要求提供更多信息。
更新:
好的,这看起来像是我的 virtualenv 的问题。在我启动这个 virtualenv 之后,我在里面做pip install django
了,但是现在如果我再次在里面输入它,我会得到以下信息:
Requirement already satisfied (use --upgrade to upgrade): django in /Library/Python/2.7/site-packages
我认为这并不指向我的 virtualenv,所以我猜这是一个问题。为什么我所在的 venv 没有安装 django?我怎样才能解决这个问题?并且下次不会遇到问题?