您的位置:首页 > 移动开发 > Objective-C

'WSGIRequest' object has no attribute 'user'

2015-08-27 18:11 639 查看
From: http://stackoverflow.com/questions/26576192/wsgirequest-object-has-no-attribute-user
I'am trying to make an auth module in my django project. But when I open my web site url I have a this error: 'WSGIRequest' object has no attribute 'user'

I've trying to find information about this problem and somebody said that the problem is in MIDDLEWARE_CLASSES but I can't understand it.

This is my MIDDLEWARE_CLASSES:

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
#'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)


Answer:

Your middleware ordering is wrong. Please read
this part carefully.The order should be:

'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: