Django - PUT/DELETE 请求中存储的参数在哪里? [英] Django - Where are the params stored on a PUT/DELETE request?

查看:57
本文介绍了Django - PUT/DELETE 请求中存储的参数在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的新 django 项目遵循 RESTful 模式,我想知道发出 PUT/DELETE 请求时参数在哪里.

I'd like to follow the RESTful pattern for my new django project, and I'd like to know where the parameters are when a PUT/DELETE request is made.

据我所知,我只看到 GET &POST QueryDict 在请求中,没有其他.Django 是针对请求添加新的 PUT 或 DELETE QueryDict,还是将参数添加到 GET 或 POST QueryDict ?

As far as I know, I only see GET & POST QueryDict in the request, no others. Is Django adding a new PUT or DELETE QueryDict regarding to the request, or does it add the parameters to GET or POST QueryDict ?

感谢您的帮助.

推荐答案

我使用的是 django v1.5.而我主要使用QueryDict来解决问题:

I am using django v1.5. And I mainly use QueryDict to solve the problem:

from django.http import QueryDict
put = QueryDict(request.body)
description = put.get('description')

在 *.coffee 中

and in *.coffee

$.ajax
      url: "/policy/#{policyId}/description/"
      type: "PUT"
      data:
        description: value
      success: (data) ->
        alert data.body
      fail: (data) ->
        alert "fail"

你可以去这里查找更多信息.我希望这可以帮助你.祝你好运:)

You can go here to find more information. And I hope this can help you. Good luck:)

这篇关于Django - PUT/DELETE 请求中存储的参数在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆