[英]Using request.body in Django compared to nodejs for building restful apis
I have just begun learning the Django framework, and my goal is too take this knowledge and use it to build a rest api. (I have considered using django-rest framework, but my job requires specifically Django).我刚刚开始学习 Django 框架,我的目标是利用这些知识并用它来构建一个 rest api。(我考虑过使用 django-rest 框架,但我的工作需要专门的 Django)。 I have already learned a medium amount of nodejs, and for this I use express.
我已经学习了中等数量的 nodejs,为此我使用了 express。 I use the req.body to enable users to enter some information.
我使用 req.body 使用户能够输入一些信息。 In Django, how would I use this req.body property to allow a user to type information.
在 Django 中,我将如何使用此 req.body 属性来允许用户键入信息。 This is purely for backend purposes (no frontend included).
这纯粹是为了后端目的(不包括前端)。 For example, sending a post request, and setting parameters.
比如发送post请求,设置参数。
Both Express and Django endpoints receive a reference to the request object. Express和Django端点都接收对请求对象的引用。 The APIs are of course different.
API当然是不同的。 Here is a rough mapping:
这是一个粗略的映射:
https://example.com/?foo=bar
): https://example.com/?foo=bar
):
foo=bar
): foo=bar
):
request.method
, which is a string like "POST"
or "GET"
. request.method
,这是一个像"POST"
或"GET"
这样的字符串。 request.body
in express is equivalent to在快递中相当于
request.POST
in django在 django
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.