[英]How to save http request to django?
I have a device that do some calculations and then i want to send it with help of request to my site:我有一个可以进行一些计算的设备,然后我想在请求的帮助下将它发送到我的网站:
import requests
params = {'data1': '47237582'}
r =requests.get("http://127.0.0.1:8000/", data = params)
print(r)
I have a django site.我有一个 django 网站。 How can i save the value of my request for later display?
我如何保存我的请求值以供以后显示?
def read(request):
if request.method == 'GET':
msg = request.GET['data1']
And how can i save it to database?我怎样才能将它保存到数据库?
msg = request.GET['data1']
store the msg with msg_obj = Message.objects.create(msg=msg, ...other-fields if any)
msg = request.GET['data1']
获取消息后使用msg_obj = Message.objects.create(msg=msg, ...other-fields if any)
存储消息 If you are gonna have different keys (ie columns) for each request, then I say you use MongoDB , which will allow you save different set of key-values in a single document.如果您要为每个请求使用不同的键(即列),那么我说您使用MongoDB ,这将允许您在单个文档中保存不同的键值集。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.