简体   繁体   English

Django中的request._cookies是什么?

[英]what is request._cookies in django?

我在应用程序的view.py中找到cookies['cpu'] = request._cookies['cpu'] ,但我不知道request._cookies['cpu']是什么,因此无法在Google或django文档。

A HTTP Cookie is data that is initially sent from the website and stored on a user's browser. HTTP Cookie是最初从网站发送并存储在用户浏览器中的数据。 This data is persistently stored, you can take a look at your cookies right now: 此数据是永久存储的,您可以立即查看Cookie:

在此处输入图片说明

在此处输入图片说明

As you can see, stackoverflow stores these cookies, and when you send a request to the server, you can the request can include data from the cookies. 如您所见,stackoverflow存储了这些cookie,并且当您向服务器发送请求时,您可以在请求中包含来自cookie的数据。 The _cookies accesses these cookies. _cookies访问这些cookie。

You couldn't find it in the docs because it doesn't exist, the original creator of the script might have chosen to add a separate attribute, this is unclear since we cannot see the views.py file itself. 您无法在文档中找到它,因为它不存在,脚本的原始创建者可能选择添加单独的属性,目前尚不清楚,因为我们看不到views.py文件本身。 The only attribute for a HTTPRequest that is relevant to what you're asking is HTTPRequest.COOKIES , which is a python dictionary of values. 与您要查询的内容相关的HTTPRequest的唯一属性是HTTPRequest.COOKIES ,这是一个python值字典。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM