Search code examples
djangodjango-piston

django piston not able to write to rc.BAD_REQUEST


I have django 1.4 and latest piston from pip as of yesterday (I tried to get the version but I didn't know how)

Everything seems to be working fine accept when I try to write to the rc.BAD_REQUEST. When I try to return the rc.BAD_REQUEST its working fine. but when I do this

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

I get the following error

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

Am not quite sure whats wrong, I have the same exact handler working fine on a different project but its 1.3.. Any advise?


Solution

  • This is apparently fixed [1] in the source tree for django-piston. You can try to install it with pip like so:

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

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