属性错误:“WSGIRequest”对象没有属性“会话”;
我不断地随机收到此错误,每当我触摸 django.wsgi 文件时,它就会被修复,但几个小时后又会再次发生。我不知道该怎么办。我的中间件类如下:
MIDDLEWARE_CLASSES = (
'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.csrf.CsrfResponseMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.facebookConnectMiddleware.FacebookConnectMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
)
当我执行“if request.session”语句时,错误总是发生在 facebook 中间件中。 谢谢
I keep getting this error at random times and whenever I touch the django.wsgi file, it gets fixed only to happen again after a few hours. I'm lost as to what to do. my middleware_classes is as follows:
MIDDLEWARE_CLASSES = (
'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.csrf.CsrfResponseMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.facebookConnectMiddleware.FacebookConnectMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
)
The error always occurs in the facebook middleware when i do an "if request.session" statement.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试末尾处记录的备用 WSGI 脚本文件:
http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html
报告是否有帮助,因为我们仍在尝试发现替代 WSGI 脚本正在解决的任何问题,从而确定是否是真正的问题或用户是否没有正确使用 Django。
Try the alternate WSGI script file documented at end of:
http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html
Report back to mod_wsgi list if that helps as we are trying still to uncover what if any problems that alternate WSGI script is solving, so can work out whether a real problem or whether users aren't using Django properly.
检查你的代码中是否写了:
正确的是
Check if in your code you have write:
the correctly are is
确保 SessionMiddleware 位于您的
MIDDLEWARE_CLASSES
中。Make sure the SessionMiddleware is first in your
MIDDLEWARE_CLASSES
.你在使用阿帕奇吗?如果是这样,您可能应该在修改 mod_wsgi 文件后重新启动 httpd。
...或类似的应该有效。如果您仍然遇到问题,请尝试粘贴完整的错误消息。
Are you using Apache? If so, you should probably restart httpd after you modify the mod_wsgi file.
... or similar should work. If you're still seeing the problem, try pasting in the full error message.