2024-09-29 06:35:06 发布
网友
request.POST和request.GET中的参数都在request.request中吗?或者我要检查每一个?
我在文档中找不到请求/QueryDict的明确信息。 注:Django 1.4决赛
试试这个:
name=request.GET.GET('name',request.POST.GET('name'))
是的,医生说:
HttpRequest.REQUEST For convenience, a dictionary-like object that searches POST first, then GET. Inspired by PHP’s $_REQUEST.For example, if GET = {"name": "john"} and POST = {"age": '34'}, REQUEST["name"] would be "john", and REQUEST["age"] would be "34".It’s strongly suggested that you use GET and POST instead of REQUEST, because the former are more explicit.
HttpRequest.REQUEST For convenience, a dictionary-like object that searches POST first, then GET. Inspired by PHP’s $_REQUEST.
For example, if GET = {"name": "john"} and POST = {"age": '34'}, REQUEST["name"] would be "john", and REQUEST["age"] would be "34".
It’s strongly suggested that you use GET and POST instead of REQUEST, because the former are more explicit.
不,这在旧版本中是可能的,但在Django 1.7中被贬值了。对于运行古代版本的Django考古学家,继续阅读。
从documentation:
HttpRequest.REQUEST请求
为了方便起见,一个类似字典的对象先搜索POST,然后再搜索GET。灵感来自PHP的$请求。
例如,如果GET={“name”:“john”}和POST={“age”:“34”},则REQUEST[“name”]将是“john”,REQUEST[“age”]将是“34”。
强烈建议您使用GET和POST而不是REQUEST,因为前者更明确。
试试这个:
name=request.GET.GET('name',request.POST.GET('name'))
是的,医生说:
不,这在旧版本中是可能的,但在Django 1.7中被贬值了。对于运行古代版本的Django考古学家,继续阅读。
从documentation:
HttpRequest.REQUEST请求
为了方便起见,一个类似字典的对象先搜索POST,然后再搜索GET。灵感来自PHP的$请求。
例如,如果GET={“name”:“john”}和POST={“age”:“34”},则REQUEST[“name”]将是“john”,REQUEST[“age”]将是“34”。
强烈建议您使用GET和POST而不是REQUEST,因为前者更明确。
相关问题 更多 >
编程相关推荐