1.django Manager isn't accessible via xxx instances
解决:在引用models对象时名字出错,注意检查是否拼写正确
#ret = user.objects.filter(username=uname)
ret = userinfo.objects.filter(username=uname)
2.context must be a dict rather than RequestContext.
在调用django的模板时出错,原因是render中的对象为一个字典类型,因为django版本的更新,1.11已经不支持t.render(requestcontext)这样的写法了
context['msg'] = '登录失败!请检查用户名或密码是否有误!'
#requestcontext = RequestContext(request,context)
#reponse = HttpResponse(t.render(requestcontext))
response = HttpResponse(t.render({'msg':'登录失败!请检查用户名或密码是否有误!'}))
3.csrf和xss
xss:跨站脚本攻击,可将接收的信息进行转义
csrf:跨域伪造请求攻击,setting中设置自动开启csrf的防范,每次提交表单带上token_csrf