django-tastypie-nonrel
django-tastypie-nonrel copied to clipboard
EmbeddedModelField fails to dehydrate when use in a resource
EmbeddedModelField fails to dehydrate in a resource. Here is the stack trace
Traceback (most recent call last): File "/home/talha/ws/elastica/lib/python2.7/site-packages/tastypie/resources.py", line 195, in wrapper response = callback(request, _args, *_kwargs) File "/home/talha/ws/elastica/lib/python2.7/site-packages/tastypie/resources.py", line 426, in dispatch_list return self.dispatch('list', request, *_kwargs) File "/home/talha/ws/elastica/lib/python2.7/site-packages/tastypie/resources.py", line 458, in dispatch response = method(request, *_kwargs) File "/home/talha/ws/elastica/lib/python2.7/site-packages/tastypie/resources.py", line 1276, in get_list bundles.append(self.full_dehydrate(bundle, for_list=True)) File "/home/talha/ws/elastica/lib/python2.7/site-packages/tastypie/resources.py", line 831, in full_dehydrate bundle.data[field_name] = field_object.dehydrate(bundle, for_list=for_list) TypeError: dehydrate() got an unexpected keyword argument 'for_list'
Now looking at the code inside tastypie_nonrel/fields.py: the dehydrate method of EmbeddedModelField is defined @ line: 103
def dehydrate(self, obj):
This doesnot match with what the resource is trying to give it. I tried this Solution
def dehydrate(self, obj, for_list=True):
and it worked. Any comments?