本文共 3036 字,大约阅读时间需要 10 分钟。
原文链接:
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.
request.path | /request/django |
request.method | GET |
request.encoding | None |
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/emptyrequest.META['GATEWAY_INTERFACE'] % CGI/1.1request.META['HTTP_ACCEPT'] % */*request.META['HTTP_ACCEPT_ENCODING'] % gzip, deflaterequest.META['HTTP_ACCEPT_LANGUAGE'] % zh-cnrequest.META['HTTP_CONNECTION'] % Keep-Aliverequest.META['HTTP_HOST'] % devhttp.comrequest.META['HTTP_REFERER'] % http://www.douban.com/group/topic/12690846/request.META['HTTP_USER_AGENT'] % Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; InfoPath.2; .NET CLR 2.0.50727; .NET4.0C; .NET4.0E; 360SE)request.META['mod_wsgi.application_group'] % www.devhttp.com|request.META['mod_wsgi.callable_object'] % applicationrequest.META['mod_wsgi.listener_host'] % request.META['mod_wsgi.listener_port'] % 80request.META['mod_wsgi.process_group'] % request.META['mod_wsgi.reload_mechanism'] % 0request.META['mod_wsgi.script_reloading'] % 1request.META['mod_wsgi.version'] % (2, 8)request.META['PATH'] % /usr/local/bin:/usr/bin:/binrequest.META['PATH_INFO'] % /request/djangorequest.META['PATH_TRANSLATED'] % /var/www/vhost/devhttp.com/devhttp/django.wsgi/request/djangorequest.META['QUERY_STRING'] % request.META['REMOTE_ADDR'] % 114.247.50.2request.META['REMOTE_PORT'] % 14958request.META['REQUEST_METHOD'] % GETrequest.META['REQUEST_URI'] % /request/djangorequest.META['SCRIPT_FILENAME'] % /var/www/vhost/devhttp.com/devhttp/django.wsgirequest.META['SCRIPT_NAME'] % request.META['SERVER_ADDR'] % 178.77.77.209request.META['SERVER_ADMIN'] % [no address given]request.META['SERVER_NAME'] % devhttp.comrequest.META['SERVER_PORT'] % 80request.META['SERVER_PROTOCOL'] % HTTP/1.1request.META['SERVER_SIGNATURE'] % request.META['SERVER_SOFTWARE'] % Apacherequest.META['wsgi.errors'] %request.META['wsgi.file_wrapper'] % request.META['wsgi.input'] % request.META['wsgi.multiprocess'] % Truerequest.META['wsgi.multithread'] % Falserequest.META['wsgi.run_once'] % Falserequest.META['wsgi.url_scheme'] % httprequest.META['wsgi.version'] % (1, 0)
This django.contrib.auth.models.User object is only interesting if you have authentication enabled. This site doesn't.
The session contains a key, randomly generated and repeated if the user is able to save the session information.
request.session['random'] = 469607171413
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 |
{% for a, bin request.META%} { { a }}:{ { b }} {% endfor %}
转载地址:http://ekxci.baihongyu.com/