开发者

AttributeError: 'WSGIRequest' object has no attribute 'session'

开发者 https://www.devze.com 2023-01-07 20:05 出处:网络
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 follo

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',
    '开发者_C百科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


Make sure the SessionMiddleware is first in your MIDDLEWARE_CLASSES.


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.


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:

del request.session

the correctly are is

del request.session['YOU VARIABLE']

0

精彩评论

暂无评论...
验证码 换一张
取 消