Python django活塞:正确格式化来自客户端应用程序的POST数据

Python django活塞:正确格式化来自客户端应用程序的POST数据,python,django,json,rest,django-piston,Python,Django,Json,Rest,Django Piston,我有一个Django应用程序第一次运行Django活塞 我已经为一个模型配置了一个处理程序,并为GET和POST装配了它 把工作做好。千真万确 然而,这篇文章很差劲。当我向它发布数据时,我得到了这个错误 Responded: Piston/0.2.3rc1 (Django 1.2.4) crash report: Method signature does not match. Resource does not expect any parameters. Exception was:

我有一个Django应用程序第一次运行Django活塞

我已经为一个模型配置了一个处理程序,并为GET和POST装配了它

把工作做好。千真万确

然而,这篇文章很差劲。当我向它发布数据时,我得到了这个错误

Responded: Piston/0.2.3rc1 (Django 1.2.4) crash report:

Method signature does not match.

Resource does not expect any parameters.

Exception was: cannot concatenate 'str' and 'dict' objects
我真的不是Python的专家,但一些基本的谷歌搜索显示,这似乎是一个相当普遍的Python类型错误

这里有一些代码

URL.py相关部分

基本上,它根本就没有创造出来,或者至少看起来没有。由于上面提到的错误,所以我甚至看不到它是如何接收数据的

这是我想发布的数据

{"words":[{"owner":{"id":1,"tags":null,"password":null,"words":null,"email":null,"firstname":null,"lastname":null,"username":null},"id":1,"sort_order":0,"tags":null,"string":"Another Test"},{"owner":{"id":1,"tags":null,"password":null,"words":null,"email":null,"firstname":null,"lastname":null,"username":null},"id":2,"sort_order":0,"tags":null,"string":"Here's a test"},{"owner":null,"id":0,"sort_order":0,"tags":null,"string":"Tampa"}]}

任何信息都会非常有用。

我自己解决了这个问题

错误的相关原因是create方法中的这一行

if request.content_type:
这并不像我认为的django活塞文档的创建者所期望的那样真实。即使值是带值的字符串

去掉这条线就解决了这个问题。我相信你可以做一个字符串计算

不太清楚他们在想什么

{"words":[{"owner":{"id":1,"tags":null,"password":null,"words":null,"email":null,"firstname":null,"lastname":null,"username":null},"id":1,"sort_order":0,"tags":null,"string":"Another Test"},{"owner":{"id":1,"tags":null,"password":null,"words":null,"email":null,"firstname":null,"lastname":null,"username":null},"id":2,"sort_order":0,"tags":null,"string":"Here's a test"},{"owner":null,"id":0,"sort_order":0,"tags":null,"string":"Tampa"}]}
if request.content_type: