request.POST在Django中包含查询字符串时的示例 [英] Example when request.POST contain query string in django
问题描述
请在request.POST包含django中的查询字符串时发布示例代码,因为我认为我的django版本存在漏洞.
Please post example code when request.POST contain query string in django, because i think my django version is bugged.
您简单不能,查询字符串始终在GET中,这是我的问题.
You simple can't, query string is always in GET, and this was my problem.
推荐答案
如果您的请求已发布:
request.method =='POST'
request.method == 'POST'
,但请求的URL包含查询字符串.例如:
but the requested url contains a query string. e.g:
/your-url?param1 =值一
/your-url?param1=value-one
您仍然可以通过以下方式获取POST参数:
you can still take POST parameters through:
request.POST.get(我的字段",无)
request.POST.get("my-field", None)
并通过以下方式查询字符串参数:
and query string parameters through:
request.GET.get("param1")
request.GET.get("param1")
始终,您可以通过REQUEST一次选择所有参数(POST和GET):
althrough, you pick up all parameters at once (POST and GET), through REQUEST:
request.REQUEST ['param1']#来自查询字符串
request.REQUEST['param1'] # comes from query string
request.REQUEST ['my-field']#来自请求正文(POST)
request.REQUEST['my-field'] # comes from request BODY (POST)
这篇关于request.POST在Django中包含查询字符串时的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!