博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Django request 信息
阅读量:4053 次
发布时间:2019-05-25

本文共 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.

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/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)

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'] = 469607171413

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

 

 

 

 

 

{% for a, bin request.META%} 

    {
{
a }}:{
{
b }} 
{% endfor %} 

 

转载地址:http://ekxci.baihongyu.com/

你可能感兴趣的文章
IntelliJ IDEA 乱码解决方案 (项目代码、控制台等)
查看>>
详解centos6和centos7防火墙的关闭
查看>>
Redis集群与插槽分配(动态新增或删除结点)
查看>>
rediscluster报错:Node is not empty
查看>>
IDEA中Git的使用
查看>>
安装kafka_2.12-2.0.0
查看>>
OpenJDK 64-Bit Server VM warning
查看>>
Linux查看端口占用情况,并强制释放占用的端口
查看>>
hashcode详解
查看>>
String类中的equals方法总结
查看>>
==和equals的区别和联系
查看>>
centOS7永久关闭防火墙(防火墙的基本使用)
查看>>
CentOS7安装MySQL冲突和问题解决小结
查看>>
CentOS下MySQL的彻底卸载
查看>>
hive lateral view语句
查看>>
scala中的函数组合器map,foreach,flatmap,flatten,filter,zip等用法
查看>>
Spark RDD API
查看>>
spark中算子详解:aggregateByKey
查看>>
Spark自定义排序
查看>>
Spark2.x 如何实现自定义排序(利用元组,类--隐式转换Ordering,Ordered等实现)
查看>>