django活塞无法写入rc.BAD_REQUEST

时间:2012-09-11 21:45:35

标签: django django-piston

我有django 1.4和最新的活塞来自pip昨天(我试图得到版本,但我不知道如何)

当我尝试写入rc.BAD_REQUEST时,一切似乎都工作正常。当我尝试返回rc.BAD_REQUEST时它工作正常。但是当我这样做时

resp = rc.CREATED
resp.write("Everything went fine!")
return resp

我收到以下错误

AttributeError at /car/api/model-lookup-model.json/allard/1956/

'HttpResponseServerError' object has no attribute '_is_string'

Request Method:     GET
Request URL:    http://127.0.0.1:8000/car/api/model-lookup-model.json/allard/1956/
Django Version:     1.4.1
Exception Type:     AttributeError
Exception Value:    

'HttpResponseServerError' object has no attribute '_is_string'

Exception Location:     /Users/mo/Projects/pythonic/garenv/lib/python2.7/site-packages/piston/resource.py in __call__, line 184
Python Executable:  /Users/mo/Projects/pythonic/garenv/bin/python
Python Version:     2.7.2

我不太确定什么是错的,我有一个完全相同的处理程序在一个不同的项目上运行良好,但它的1.3 ..任何建议?

2 个答案:

答案 0 :(得分:6)

这在django-piston的源代码树中显然是固定的[1]。您可以尝试使用pip安装它,如下所示:

pip install hg+https://bitbucket.org/jespern/django-piston

[1] https://bitbucket.org/jespern/django-piston/changeset/7c90898072ce9462a6023bbec5d408ad097a362b

答案 1 :(得分:0)

我尝试在Mac OS(Mavericks)上执行“pip install hg + https://bitbucket.org/jespern/django-piston”,但是没有用。我收到此错误消息:

  

下载/解压缩hg + https://bitbucket.org/jespern/django-piston

     

将hg https://bitbucket.org/jespern/django-piston克隆到/ var / folders / kr / 06j9n8kj2fd0dbfs0_sf54q00000gn / T / pip-PwNUCl-build

     

清理......

     

找不到命令'hg'

     

在/Users/marcelosoares/.pip/pip.log中存储失败的调试日志

更新:

之前需要卸载django-piston并且需要安装Mercurial。我刚刚安装并工作了:

  

https://www.mercurial-scm.org/downloads