Django教程:runserver错误 [英] Django tutorial: runserver error
问题描述
我正在关注django教程,我立即遇到了第1部分的问题。运行python manage.py runserver之后,我将URL输入到我的浏览器并收到错误:
I'm following the django tutorial and i immediately ran into a problem on part 1. After running python manage.py runserver i enter the URL into my browser and get an error:
ImproperlyConfigured: Module "django.contrib.auth.middleware" does not define a "SessionAuthenticationMiddleware" attribute/class"
下面我包含错误以及我正在运行的python和django的版本。任何帮助将非常感谢
Below i included the error along with the version of python and django i'm running. Any help would be much appreciated
^C172-29-17-104:mysite [redacted]$ python -V
Python 2.7.5
172-29-17-104:mysite [redacted]$ python -c "import django; print(django.get_version())"
1.6.4
172-29-17-104:mysite [redacted]$ python manage.py runserver
Validating models...
0 errors found
October 01, 2014 - 20:12:56
Django version 1.6.4, using settings 'mysite.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 47, 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
[01/Oct/2014 20:13:44] "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/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 47, 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/classpython manage.py runserver
推荐答案
看起来您正在使用版本1.7之前的django版本(1.6.4)和 SessionAuthenticationMiddleware
直到django 1.7才引入。因此错误
It looks like you are using a version of django prior to version 1.7 (1.6.4 to be specific), and SessionAuthenticationMiddleware
was not introduced until django 1.7. Hence the error
在右下角,您可以选择django的版本。选择适当的版本,并按照您正在使用的django版本具体的教程。
On the bottom right, you can choose the version of django. Select the appropriate version, and follow the tutorial specific to the version of django you are using.
这篇关于Django教程:runserver错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!