属性错误:“WSGIRequest”对象没有属性“会话”;

发布于 2024-09-09 10:45:25 字数 832 浏览 7 评论 0原文

我不断地随机收到此错误,每当我触摸 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

生死何惧 2024-09-16 10:45:26

尝试末尾处记录的备用 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.

暖心男生 2024-09-16 10:45:26

检查你的代码中是否写了:

删除请求.session

正确的是

del request.session['您的变量']

Check if in your code you have write:

del request.session

the correctly are is

del request.session['YOU VARIABLE']

漆黑的白昼 2024-09-16 10:45:25

确保 SessionMiddleware 位于您的 MIDDLEWARE_CLASSES 中。

Make sure the SessionMiddleware is first in your MIDDLEWARE_CLASSES.

嘦怹 2024-09-16 10:45:25

你在使用阿帕奇吗?如果是这样,您可能应该在修改 mod_wsgi 文件后重新启动 httpd。

sudo apachectl -k restart
sudo apache2ctl -k restart
sudo /etc/init.d/httpd restart

...或类似的应该有效。如果您仍然遇到问题,请尝试粘贴完整的错误消息。

Are you using Apache? If so, you should probably restart httpd after you modify the mod_wsgi file.

sudo apachectl -k restart
sudo apache2ctl -k restart
sudo /etc/init.d/httpd restart

... or similar should work. If you're still seeing the problem, try pasting in the full error message.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文