1
因此Im爲Django的用戶帳戶 即時得到的錯誤消息「WSGIRequest」對象沒有屬性「用戶」的文檔以下文件要求把這個代碼Django的用戶帳戶的WSGIRequest'對象沒有屬性「用戶」
MIDDLEWARE_CLASSES = [
...
"account.middleware.LocaleMiddleware",
"account.middleware.TimezoneMiddleware",
...
]
MIDDLEWARE_CLASSES已過時,所以我把兩行代碼,在短短的中間件。
INSTALLED_APPS = [
'account',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.sites',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
"account.middleware.LocaleMiddleware",
"account.middleware.TimezoneMiddleware",
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
根urls.py
from django.conf.urls import url, include
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r"^account/", include("account.urls")),
]
我跑makemigrations爲賬戶,和我跑遷移。服務器用盡只是沒有錯誤罰款,但每當我去本地主機:8000 /帳號/登錄我要麼得到一個或沒有屬性「用戶」
什麼Django的版本是您使用?另外,可能使用django 1.10.5重複http://stackoverflow.com/questions/37949198/wsgirequest-object-has-no-attribute-user-django-admin – helb
,我查看了其他問題,但沒有答案實際上幫助 – jalen201
感謝那個鏈接是我需要的 – jalen201