這是Django版本的問題喧半,1.9之前食店,中間件的key為MIDDLEWARE_CLASSES, 1.9之后惧磺,為MIDDLEWARE颖对。所以在開發(fā)環(huán)境和其他環(huán)境的版本不一致時(shí),要特別小心磨隘,會(huì)有坑缤底。
將settings里的MIDDLEWARE_CLASSES默認(rèn)配置順序改成如下
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]