使用django-rest-interface与http put [英] using django-rest-interface with http put
问题描述
我试图找出如何使用Django和django-rest-interface实现我的第一个RESTful界面。我有HTTP PUT请求的问题。
I'm trying to figure out how to implement my first RESTful interface using Django and django-rest-interface. I'm having problems with the HTTP PUT requests.
如何访问PUT请求的参数?
我以为他们会在request.POST数组中,因为PUT在我的理解中有点类似于POST,但该数组始终为空。
How do I access the parameters of the PUT request? I thought they would be in the request.POST array, as PUT is somewhat similar to POST in my understanding, but that array is always empty.
什么我做错了?
感谢您的帮助
推荐答案
请求.POST将表单编码的数据处理成字典,这对于Web浏览器表单提交只是有意义的。没有PUT的等同物,因为网络浏览器不是PUT表单;提交的数据可能有任何内容类型。您需要从request.raw_post_data中获取原始数据,可能检查内容类型,然后处理它对您的应用程序是有意义的。
request.POST processes form-encoded data into a dictionary, which only makes sense for web browser form submissions. There is no equivalent for PUT, as web browsers don't PUT forms; the data submitted could have any content type. You'll need to get the raw data out of request.raw_post_data, possibly check the content type, and process it however makes sense for your application.
a href =http://groups.google.com/group/django-developers/browse_thread/thread/771238a95ceb058e =noreferrer>这个线程。
More information in this thread.
这篇关于使用django-rest-interface与http put的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!