class HttpRequest 1.attribute: HttpRequest.user
django.contrib.auth.models.User 对象 ,代表当前登录的用户,如果当前用户没有登录,用户将被设置为django.contrib.auth.modesl.AnonymousUser的一个实例,你可以用is_authenticated()来验证他们,if request.user.is_authenticated():
do something for logged-in users.
else:
do sth for anonymous users.
只有当你的django installation 的AuthenticationMiddleware 激活后。user才可用。
HttpRequest.GET HttpRequest.POST 返回像字典一样的对象,对应为get请求和post请求参数
HttpRequest.REQUEST 返回字典对象,首先搜索post,其次搜索get
HttpRequest.COOKIES 包含客户端请求的所有cookie标准的Python字典对象,
HttpRequest.FILES 像字典对象,包含所有的上传文件。FILES中的名字是<input type="file" name=""/>中的name,值是上传的文件
HttpRequest.session 可读写的像字典一样的对象,代表了当前的session,This is only available if your Django installation has session support activated。