Ash*_*rma 5 django django-templates django-views
嗨,我正在制作一个网络服务器,我必须在其中点击来自 html 页面的一些请求并返回响应。使用 html 生成的 URL 是
但在服务器端我看不到请求数据。我正在使用
q = QueryDict(request.body)但它显示<QueryDict: {}>
如何找到请求中的所有参数。
在您的情况下,您在 url 中发送数据,以便通过request.GET以下方式访问数据:
username = request.GET.get('Username')
start_date = request.GET.get('startDate')
# ... the same for all the other parameter after the `?` marque.
Run Code Online (Sandbox Code Playgroud)
实际上request data,request.body、request.GET和之间存在差异request.POST:
request.body或 中访问请求数据request.POST。request.data. 您也可能在 Internetrequest.DATA上发现这是正确的,但它在较新版本的 DRF 中已被弃用,而支持 request.data。request.GET按照上面的说明访问数据表单。| 归档时间: |
|
| 查看次数: |
4370 次 |
| 最近记录: |