Django request session cookie

django web Cookie 和 Sessions 应用

http://www.cnblogs.com/lhj588/archive/2011/10/27/2226976.html


Django request variables, these lines assume you are inside a view according to: 



def yourview(request, ...):This page is based on the Request and response objects page in the Django 1 documentation. 

HttpRequest attributes 
request.path /request/django 
request.method GET 
request.encoding None 

HttpRequest.META 
A standard Python dictionary containing all available HTTP headers. Available headers depend on the client and server, but here are some examples: 

request.META['DOCUMENT_ROOT'] % /var/www/empty 
request.META['GATEWAY_INTERFACE'] % CGI/1.1 
request.META['HTTP_ACCEPT'] % */* 
request.META['HTTP_ACCEPT_ENCODING'] % gzip, deflate 
request.META['HTTP_ACCEPT_LANGUAGE'] % zh-cn 
request.META['HTTP_CONNECTION'] % Keep-Alive 
request.META['HTTP_HOST'] % devhttp.com 
request.META['HTTP_REFERER'] %  http://www.google.com.hk/search?q=django%20request.META.SERVER_SIGNATURE  
request.META['HTTP_USER_AGENT'] % Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; FDM; .NET CLR 2.0.50727; GreenBrowser) 
request.META['mod_wsgi.application_group'] %  www.devhttp.com
request.META['mod_wsgi.callable_object'] % application 
request.META['mod_wsgi.listener_host'] % 
request.META['mod_wsgi.listener_port'] % 80 
request.META['mod_wsgi.process_group'] % 
request.META['mod_wsgi.reload_mechanism'] % 0 
request.META['mod_wsgi.script_reloading'] % 1 
request.META['mod_wsgi.version'] % (2, 5) 
request.META['PATH'] % /usr/local/bin:/usr/bin:/bin 
request.META['PATH_INFO'] % /request/django 
request.META['PATH_TRANSLATED'] % /var/www/vhost/devhttp.com/devhttp/django.wsgi/request/django 
request.META['QUERY_STRING'] % 
request.META['REMOTE_ADDR'] % 61.163.210.142 
request.META['REMOTE_PORT'] % 49506 
request.META['REQUEST_METHOD'] % GET 
request.META['REQUEST_URI'] % /request/django 
request.META['SCRIPT_FILENAME'] % /var/www/vhost/devhttp.com/devhttp/django.wsgi 
request.META['SCRIPT_NAME'] % 
request.META['SERVER_ADDR'] % 92.51.129.134 
request.META['SERVER_ADMIN'] % [no address given] 
request.META['SERVER_NAME'] % devhttp.com 
request.META['SERVER_PORT'] % 80 
request.META['SERVER_PROTOCOL'] % HTTP/1.1 
request.META['SERVER_SIGNATURE'] % 
request.META['SERVER_SOFTWARE'] % Apache 
request.META['wsgi.errors'] % <mod_wsgi.Log object at 0x9af9b18> 
request.META['wsgi.file_wrapper'] % <built-in method file_wrapper of mod_wsgi.Adapter object at 0x9c3e9b0> 
request.META['wsgi.input'] % <mod_wsgi.Input object at 0x9c55d68> 
request.META['wsgi.multiprocess'] % True 
request.META['wsgi.multithread'] % False 
request.META['wsgi.run_once'] % False 
request.META['wsgi.url_scheme'] % http 
request.META['wsgi.version'] % (1, 0) 
request.user 
This django.contrib.auth.models.User object is only interesting if you have authentication enabled. This site doesn't. 

request.session 
The session contains a key, randomly generated and repeated if the user is able to save the session information. 

request.session['random'] = 309762054148 
HttpRequest methods 
request.get_host() devhttp.com 
request.get_full_path() /request/django 
request.build_absolute_uri()  http://devhttp.com/request/django  
request.is_secure() False 
request.is_ajax() False 


http://devhttp.com/request/django
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值