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.co
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/r
request.is_secure() False
request.is_ajax() False
http://devhttp.com/r