每当我用我的django项目运行我的本地服务器时,我收到一条警告和一条错误消息,说在Django 1.7中全局中间件类已经改变 - 即使我使用的是1.8.我的博客,在http://127.0.0.1:8000/,加载正常,但当我尝试加载我得到的管理网站AttributeError at /admin/ 'WSGIRequest' object has no attribute 'user'
,据我所知,这是与中间件.感谢您的帮助
编辑:我的中间件:
MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ]
错误信息:
Warnings ?: (1_7.W001) Middleware_Classes is not set. Hint: Django 1.7 changed the global defaults for the middleware_classes. django.contrib.auth.middleware.AuthenticationMiddleware, django.contrib.sessions.middleware.SessionMiddleware, and django.contrib.messages.middleware.MessageMiddleware, were removed from the defaults. If your project needs this middleware then you should configure this middleware.
Alasdair.. 9
该MIDDLEWARE
设置是在Django 1.10中引入的.如果您使用的是Django 1.9或更早版本,它将无效,您应该使用该MIDDLEWARE_CLASSES
设置.
确保您使用的是正确版本的文档(例如Django 1.8,Django 1.11),以便您遵循正确的说明.
该MIDDLEWARE
设置是在Django 1.10中引入的.如果您使用的是Django 1.9或更早版本,它将无效,您应该使用该MIDDLEWARE_CLASSES
设置.
确保您使用的是正确版本的文档(例如Django 1.8,Django 1.11),以便您遵循正确的说明.