Open Jcbobo opened 9 years ago
Have you tried to send your request with "format='json" parameter in client.post()?
@Jcbobo88 can you post your test case?
I face the same isse while posting list of objects in "post" method. when
data = [
{
'contact.created': "2016-10-12T12:31:08.553139Z",
'contact.modified': "2016-10-12T12:31:08.566822Z",
'contact.status': 1,
},
{
'contact.created': "2016-10-12T12:31:08.553139Z",
'contact.modified': "2016-10-12T12:31:08.566822Z",
'contact.status': 1,
},
]
to
response = self.c.post(self._url, data, format='json') AttributeError: 'list' object has no attribute 'items'
To whoever finds this issue, passing it as a JSONified string solved it for me:
import json
# [...]
self.client.post(self.view_url, json.dumps(data), content_type='application/json')
Keep in mind that I'm not using this framework, I'm doing bulk actions manually in my code, but the error and the situation were the same, so I believe it should work.
I'm trying to wrote test for my application ( I have bulk creation on one api ) but iI'm blocked because the rest_framework api client does not allow me to execute post with a list as data error:
I'm working on osx yosemite 10.10.3 pip freeze with virtualenv actived:
Django==1.8.2 -e https://github.com/umutbozkurt/django-rest-framework-mongoengine#egg=django_rest_framework_mongoengine-master djangorestframework==3.1.3 djangorestframework-bulk==0.2.1 mongoengine==0.9.0 pymongo==2.8.1 wsgiref==0.1.2
no problem on creation,update reported