27👍
✅
As far as I know, httpie
sends a request with the content-type application/json
.
So, try this:
import json
data = json.dumps({'text': 'new text'})
client.patch('/post/1/', data, content_type='application/json')
0👍
As for why you need to add a content_type
for PATCH
(and PUT
, OPTIONS
, DELETE
). It’s because Django uses different defaults for content_type
. For post
it uses multipart/form-data
while for the others it uses application/octet-stream
. Not 100% sure why, but that explains the POST/GET
succeeding
- Django Inner Join Queryset
- What could cause a Django error when debug=False that isn't there when debug=True
- "no such table" error on Heroku after django syncdb passed
- Django CMS malfunction: Site matching query does not exist
Source:stackexchange.com