Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python django-request.META-发送请求时,如何使数据显示在request.META中_Python_Django - Fatal编程技术网

Python django-request.META-发送请求时,如何使数据显示在request.META中

Python django-request.META-发送请求时,如何使数据显示在request.META中,python,django,Python,Django,在Django中,request.META中包含许多内容,我当前的代码在request.META中检查类似HTTP_标记的内容,因此在发送请求时,我需要将请求发送到该url,以便在接收服务器中,数据显示在request.META中 我以为标题会出现在那里,所以我尝试了以下方法: python example:(I am sending request from javascript, but getting it work from any client is enough so I can

在Django中,request.META中包含许多内容,我当前的代码在request.META中检查类似HTTP_标记的内容,因此在发送请求时,我需要将请求发送到该url,以便在接收服务器中,数据显示在request.META中

我以为标题会出现在那里,所以我尝试了以下方法:

  python example:(I am sending request from javascript, but getting it work from any client is enough so I can implement finally using javascript).
  r = requests.get(url, headers={'HTTP_TOKEN': 'abc'})

但是在收到该请求后,我在request.META中没有找到类似HTTP_标记的内容。

除了内容长度和内容类型之外,如上所述,请求中的任何HTTP头都会通过将所有字符转换为大写字母来转换为元键,用下划线替换任何连字符,并在名称中添加HTTP_uuu前缀。因此,例如,一个名为X-Bender的头将被映射到元键HTTP_X_Bender。

因此,在您的情况下,我认为您只需发送
{“TOKEN”:“abc”}