gpt4 book ai didi

python - Django 教程 : runserver error

转载 作者:太空宇宙 更新时间:2023-11-03 14:22:13 25 4
gpt4 key购买 nike

我正在学习 django 教程,但在第 1 部分中立即遇到了问题。运行 python manage.py runserver 后,我在浏览器中输入了 URL 并收到错误消息:

ImproperlyConfigured: Module "django.contrib.auth.middleware" does not define a "SessionAuthenticationMiddleware" attribute/class"

下面我包括了错误以及我正在运行的 python 和 django 的版本。任何帮助将不胜感激

^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 才引入。因此错误

Documentation can be found here

右下角可以选择django的版本。选择适当的版本,并按照特定于您所使用的 django 版本的教程进行操作。

关于python - Django 教程 : runserver error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26149876/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com