微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Django之views视图函数

<div class="markdown-here-wrapper" data-md-url="https://i.cnblogs.com/EditPosts.aspx?postid=9902600"&gt;
<p style="margin: 0px 0px 1.2em !important; font-size: 16px; line-height: 1.75em; padding-right: 0.5em; padding-left: 0.5em;">views视图函数属于MTV中逻辑处理的部分视图函数包含着两个对象,HttpRequest对象和HttpResponse对象


<h1 id="-httprequest-" style="margin: 20px 0px 10px; padding: 0px; font-weight: bold; color: black; font-size: 24px; border-bottom: 2px solid #aaaaaa;">一.HttpRequest对象
<p style="margin: 0px 0px 1.2em !important; font-size: 16px; line-height: 1.75em; padding-right: 0.5em; padding-left: 0.5em;">HttpRequest对象在Django中会认传到views函数中作为第一个参数


<h3 id="httprequest-" style="margin: 20px 0px 10px; padding: 0px; font-weight: bold; color: black; font-size: 20px; border-bottom: 1px solid #aaaaaa;">HttpRequest的属性
<table style="margin: 1.2em 0px; padding: 0px; border-collapse: collapse; border-spacing: 0px; font: inherit; border: 0px;">

ottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: #cccccc; background-color: white; margin: 0px; padding: 0px;"> 属性 ottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: #cccccc; background-color: white; margin: 0px; padding: 0px;"> 页面的全路径,不包括域名</tr>
<tr style="border-width: 1px 0px 0px; border-right-style: initial; border-bottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: #cccccc; background-color: #f8f8f8; margin: 0px; padding: 0px;">
<td style="text-align: center; font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">method</td>
<td style="font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">请求中使用的HTTP方法</td>

</tr>
<tr style="border-width: 1px 0px 0px; border-right-style: initial; border-bottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: #cccccc; background-color: white; margin: 0px; padding: 0px;">
<td style="text-align: center; font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">GET</td>
<td style="font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">包含所有HTTP GET参数的类字典对象</td>

</tr>
<tr style="border-width: 1px 0px 0px; border-right-style: initial; border-bottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: #cccccc; background-color: #f8f8f8; margin: 0px; padding: 0px;">
<td style="text-align: center; font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">POST</td>
<td style="font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">包含所有HTTP POST参数的类字典对象</td>

</tr>
<tr style="border-width: 1px 0px 0px; border-right-style: initial; border-bottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: #cccccc; background-color: white; margin: 0px; padding: 0px;">
<td style="text-align: center; font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">REQUEST</td>
<td style="font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">该属性是POST和GET属性的集合体,先查找POST属性,然后再查找GET属性</td>

</tr>
<tr style="border-width: 1px 0px 0px; border-right-style: initial; border-bottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: #cccccc; background-color: #f8f8f8; margin: 0px; padding: 0px;">
<td style="text-align: center; font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">COOKIES</td>
<td style="font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">包含所有cookies的标准Python字典对象</td>

</tr>
<tr style="border-width: 1px 0px 0px; border-right-style: initial; border-bottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: #cccccc; background-color: white; margin: 0px; padding: 0px;">
<td style="text-align: center; font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">FILES</td>
<td style="font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">包含所有上传文件的类字典对象。FILES中的每个Key都是标签中name属性的值. FILES中的每个value 同时也是一个标准Python字典对象,包含下面三个Keys: filename: 上传文件名,用Python字符串表示 content-type: 上传文件的Content type content: 上传文件的原始内容</td>

</tr>
<tr style="border-width: 1px 0px 0px; border-right-style: initial; border-bottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: #cccccc; background-color: #f8f8f8; margin: 0px; padding: 0px;">
<td style="text-align: center; font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">Meta</td>
<td style="font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">包含所有可用HTTP头部信息的字典</td>

</tr>
<tr style="border-width: 1px 0px 0px; border-right-style: initial; border-bottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: #cccccc; background-color: white; margin: 0px; padding: 0px;">
<td style="text-align: center; font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">user</td>
<td style="font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">是一个django.contrib.auth.models.User 对象,代表当前登录用户。如果访问用户当前没有登录,user将被初始化为django.contrib.auth.models.AnonymousUser的实例</td>

</tr>
<tr style="border-width: 1px 0px 0px; border-right-style: initial; border-bottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: #cccccc; background-color: #f8f8f8; margin: 0px; padding: 0px;">
<td style="text-align: center; font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">session</td>
<td style="font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">唯一可读写的属性,代表当前会话的字典对象。只有激活Django中的session支持时该属性才可用</td>

</tr>
<tr style="border-width: 1px 0px 0px; border-right-style: initial; border-bottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: #cccccc; background-color: white; margin: 0px; padding: 0px;">
<td style="text-align: center; font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">raw_post_data</td>
<td style="font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">原始HTTP POST数据,未解析过</td>

</tr>

ottom: 1px solid #aaaaaa;">HttpRequest的方法: ottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: #cccccc; background-color: white; margin: 0px; padding: 0px;"> ottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: #cccccc; background-color: white; margin: 0px; padding: 0px;"> ottom: 2px solid #aaaaaa;">二.HttpResponse对象

用户发送一个相应,一般返回的就是让浏览器去渲染的前端页面。例如:

display: block; overflow: auto; overflow-x: auto; background: black; color: #eaeaea; text-size-adjust: none;">
 django.shortcuts  HttpResponse

<span class="hljs-function" style="color: #7aa6da;"><span class="hljs-keyword" style="color: #c397d8;">def <span class="hljs-title" style="color: #969896;">login<span class="hljs-params" style="color: #e78c45;">(req):
<span class="hljs-keyword" style="color: #c397d8;">return HttpResponse(<span class="hljs-string" style="color: #b9ca4a;">"welcome")


<p style="margin: 0px 0px 1.2em !important; font-size: 16px; line-height: 1.75em; padding-right: 0.5em; padding-left: 0.5em;">在HttpResponse的基础上拓展了两个常用方法render方法和redirect方法


<h3 id="render-" style="margin: 20px 0px 10px; padding: 0px; font-weight: bold; color: black; font-size: 20px; border-bottom: 1px solid #aaaaaa;">render方法
<p style="margin: 0px 0px 1.2em !important; font-size: 16px; line-height: 1.75em; padding-right: 0.5em; padding-left: 0.5em;">render方法用于将有关信息利用模板添加到要给用户发送的html文档中render方法的参数:


<ul style="margin: 1.2em 0px; padding-left: 2em; list-style-type: square; font-size: 16px;">
<li style="margin: 0.5em 0px; font-size: 16px;">request:即视图函数中的HttpRequest对象,也就是第一个参数
<li style="margin: 0.5em 0px; font-size: 16px;">template_name:templates 中定义的文件,也就是html文档
<li style="margin: 0.5em 0px; font-size: 16px;">context: 要传入html文档中用于渲染呈现的数据,认是字典格式。也可以使用locals(),表示将函数中所有的变量传给模板
<li style="margin: 0.5em 0px; font-size: 16px;">content_type: 生成的文档要使用的MIME 类型。认为DEFAULT_CONTENT_TYPE 设置的值
<li style="margin: 0.5em 0px; font-size: 16px;">status: http的响应代码,认是200
<li style="margin: 0.5em 0px; font-size: 16px;">using: 用于加载模板使用的模板引擎的名称

display: block; overflow: auto; overflow-x: auto; background: black; color: #eaeaea; text-size-adjust: none;">
 arams" style="color: #e78c45;">(req):
     render(req,,{:})

ottom: 1px solid #aaaaaa;">redirect方法

方法表示重定向,参数可以一个完整的url路径如”一个本网站的分支路径如"/login/“这里有一点要注意,如果redirect的路径中写的是”login/“,即没有前面那一个“/”,那么会重定向到你当前页面的路径后再加上”login/“的那个路径。redirect方法与render方法的区别在于redirect方法会重新走一遍重定向路径的视图函数的逻辑,render方法只是直接返回一个页面,上方的地址栏中的路径还是原来的路径。

cxvlc3Tlr7nosaHl koxIdHRwUmVzcG9uc2Xlr7noSAE8L3A+PHA+I+S4gC5IdHRwUmVxdWVzdOWvueixoTwvcD48cD5I dHRwUmVxdWVzdOWvueixoeWcqERqYW5nb+S4reS8mum7mOiupOS8oOWIsHZpZXdz5Ye95pWw5Lit 5L2c5Li656ys5LiA5Liq5Y+C5pWwPC9wPjxwPiMjI0h0dHBSZXF1ZXN055qE5bGe5oCn77yaPC9w PjxwPnwg5bGe5oCnIHwg6K+05piOIHw8YnI+fDotLS0tLS0tLS0tLS0tOnwtLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tfDxicj58ICAgICAgcGF0aCAgICAgfCDo r7fmsYLpobXpnaLnmoTlhajot6/lvoQs5LiN5YyF5ous5Z+f5ZCNICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg fDxicj58ICAgICBtZXRob2QgICAgfCDor7fmsYLkuK3kvb/nlKjnmoRIVFRQ5pa55rOVICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIHw8YnI+fCAgICAgIEdFVCAgICAgIHwg5YyF5ZCr5omA5pyJSFRU UCBHRVTlj4LmlbDnmoTnsbvlrZflhbjlr7noSAEgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfDxicj58ICAgICAgUE9T VCAgICAgfCDljIXlkKvmiYDmnIlIVFRQIFBPU1Tlj4LmlbDnmoTnsbvlrZflhbjlr7noSAEgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICB8PGJyPnwgICAgUkVRVUVTVCAgICB8IOivpeWxnuaAp+aYr1BPU1TlkoxHRVTlsZ7m gKfnmoTpm4blkIjkvZPvvIzlhYjmn6Xmib5QT1NU5bGe5oCn77yM54S25ZCO5YaN5p+l5om+R0VU 5bGe5oCnICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8PGJyPnwgICAgQ09P S0lFUyAgICB8IOWMheWQq+aJgOaciWNvb2tpZXPnmoTmoIflh4ZQeXRob27lrZflhbjlr7noSAEg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgfDxicj58ICAgICBGSUxFUyAgICAgfCDljIXlkKvmiYDmnInkuIrkvKDmlofku7bn moTnsbvlrZflhbjlr7nosaHjgIJGSUxFU+S4reeahOavj+S4qktleemDveaYryZhbXA7PHNwYW4g Y2xhc3M9ImhsanMtbGl0ZXJhbCI+bHQ7PC9zcGFuPmlucHV0IHR5cGU9ImZpbGUiIG5hbWU9IiIg LyZhbXA7ZzxzcGFuIGNsYXNzPSJobGpzLWxpdGVyYWwiPnQ7PC9zcGFuPuagh+etvuS4rW5hbWXl sZ7mgKfnmoTlgLwuIEZJTEVT5Lit55qE5q+P5LiqdmFsdWUg5ZCM5pe25Lmf5piv5LiA5Liq5qCH 5YeGUHl0aG9u5a2X5YW45a+56LGh77yM5YyF5ZCr5LiL6Z2i5LiJ5LiqS2V5czogZmlsZW5hbWU6 IOS4iuS8oOaWh+S7tuWQjSznlKhQeXRob27lrZfnrKbkuLLooajnpLogY29udGVudC10eXBlOiDk uIrkvKDmlofku7bnmoRDb250ZW50IHR5cGUgY29udGVudDog5LiK5Lyg5paH5Lu255qE5Y6f5aeL 5YaF5a65IHw8YnI+fCAgICAgIE1FVEEgICAgIHwg5YyF5ZCr5omA5pyJ5Y+v55SoSFRUUOWktOmD qOS/oeaBr+eahOWtl+WFuCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHw8YnI+fCAgICAgIHVzZXIgICAgIHwg5piv 5LiA5LiqZGphbmdvLmNvbnRyaWIuYXV0aC5tb2RlbHMuVXNlciDlr7nosaHvvIzku6PooajlvZPl iY3nmbvlvZXnmoTnlKjmiLfjgILlpoLmnpzorr/pl67nlKjmiLflvZPliY3msqHmnInnmbvlvZXv vix1c2Vy5bCG6KKr5Yid5aeL5YyW5Li6ZGphbmdvLmNvbnRyaWIuYXV0aC5tb2RlbHMuQW5vbnlt b3VzVXNlcueahOWunuS+iyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICB8PGJyPnwgICAgc2Vzc2lvbiAgICB8IOWUr+S4gOWPr+iv u+WGmeeahOWxnuaAp++8jOS7o+ihqOW9k+WJjeS8muivneeahOWtl+WFuOWvueixoeOAguWPquac iea/gOa0u0RqYW5nb+S4reeahHNlc3Npb27mlK/mjIHml7bor6XlsZ7mgKfmiY3lj6/nlKggICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgIHw8YnI+fCByYXdfcG9zdF9kYXRhIHwg5Y6f5aeLSFRUUCBQT1NU5pWw5o2u 77yM5pyq6Kej5p6Q6L+HICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfDwvcD48cD4mbmJzcDsjIyNIdHRwUmVx dWVzdOeahOaWueazle+8mjwvcD48cD58IOaWueazlSB8IOivtOaYjib8PGJyPnw6LS0tLS0tLS0t LS0tLS0tLTp8LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS18PGJyPnwgX19nZXRpdGVtX18oa2V5KSB8IOi/lOWbnkdFVC9QT1NU55qE6ZSu5YC8 LOWFiOWPllBPU1Qs5ZCO5Y+WR0VUICAgICAgICAgICAgICAgICAgICB8PGJyPnwgICAgIGhhc19r ZXkoKSAgICB8IOajgOafpXJlcxvlc3QuR0VUIG9yIHJlcxvlc3QuUE9TVOS4reaYr+WQpuWMheWQ q+WPguaVsOaMh+WumueahEtleSB8PGJyPnwgIGdldF9mdWxsX3BhdGgoKSB8IOi/lOWbnuWMheWQ q+afpeivouWtl+espuS4sueahOivt+axgui3r+W+hO+8jOWMheWQq2dldOaWueW8j+WPkemAgeea hOaVsOaNriAgICB8PGJyPnwgICAgaXNfc2VjdXJlKCkgICB8IOWmguaenOivt+axguaYr+WuieWF qOeahO+8jOi/lOWbnlRydWUgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHw8L3A+PHA+I+S6 jC5IdHRwUmVzcG9uc2Xlr7noSA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d1cz0imsI+PC9wPg==">​

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐


方法
(key)</tr>
<tr style="border-width: 1px 0px 0px; border-right-style: initial; border-bottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: #cccccc; background-color: #f8f8f8; margin: 0px; padding: 0px;">
<td style="text-align: center; font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">has_key()</td>
<td style="font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">检查request.GET or request.POST中是否包含参数指定的Key</td>

</tr>
<tr style="border-width: 1px 0px 0px; border-right-style: initial; border-bottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: #cccccc; background-color: white; margin: 0px; padding: 0px;">
<td style="text-align: center; font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">get_full_path()</td>
<td style="font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">返回包含查询字符串的请求路径,包含get方式发送的数据</td>

</tr>
<tr style="border-width: 1px 0px 0px; border-right-style: initial; border-bottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: #cccccc; background-color: #f8f8f8; margin: 0px; padding: 0px;">
<td style="text-align: center; font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">is_secure()</td>
<td style="font-size: 1em; border: 1px solid #cccccc; margin: 0px; padding: 0.5em 1em;">如果请求是安全的,返回True</td>

</tr>