【问题标题】:django piston not able to write to rc.BAD_REQUESTdjango 活塞无法写入 rc.BAD_REQUEST
【发布时间】:2012-09-11 21:45:35
【问题描述】:

截至昨天,我有 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 .. 有什么建议吗?

【问题讨论】:

    标签: django django-piston


    【解决方案1】:

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

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

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

    【讨论】:

      【解决方案2】:

      我尝试在 Mac OS(小牛队)上执行“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

      【讨论】:

        猜你喜欢
        • 2012-04-26
        • 1970-01-01
        • 1970-01-01
        • 2012-09-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-01-25
        • 1970-01-01
        相关资源
        最近更新 更多