1.django Manager isn't accessible via xxx instances
解決:在引用models對(duì)象時(shí)名字出錯(cuò)摔寨,注意檢查是否拼寫正確
#ret = user.objects.filter(username=uname)
ret = userinfo.objects.filter(username=uname)
2.context must be a dict rather than RequestContext.
在調(diào)用django的模板時(shí)出錯(cuò),原因是render中的對(duì)象為一個(gè)字典類型岁忘,因?yàn)閐jango版本的更新至朗,1.11已經(jīng)不支持t.render(requestcontext)這樣的寫法了
context['msg'] = '登錄失斣谢洹踊沸!請(qǐng)檢查用戶名或密碼是否有誤!'
#requestcontext = RequestContext(request,context)
#reponse = HttpResponse(t.render(requestcontext))
response = HttpResponse(t.render({'msg':'登錄失斎ㄏ恕!請(qǐng)檢查用戶名或密碼是否有誤乌妒!'}))
3.csrf和xss
xss:跨站腳本攻擊汹想,可將接收的信息進(jìn)行轉(zhuǎn)義
csrf:跨域偽造請(qǐng)求攻擊,setting中設(shè)置自動(dòng)開啟csrf的防范撤蚊,每次提交表單帶上token_csrf