KeyError when trying PUT with self reference field

21 views
Skip to first unread message

Tom McKenzie

unread,
Dec 28, 2015, 9:30:51 PM12/28/15
to Tastypie
Hi

We have a model called list that has reference to itself that looks like 

parent = models.ForeignKey('list', blank=True, null=True)

And we get this error for some (but not all) PUT request.

Note this model also has a many to many for list order
items = models.ManyToManyField(Item, through='ListItem', related_name = 'lists')

Any ideas? 

Thanks in advance,
Tom

Traceback:
File "/usr/local/lib/ours/common/api/resources.py" in wrapper
  145.                 response = callback(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/tastypie/resources.py" in dispatch_detail
  441.         return self.dispatch('detail', request, **kwargs)
File "/usr/local/lib/ours/common/api/cache.py" in dispatch
  274.                 return super(CachedResource, self).dispatch(request_type, request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/tastypie/resources.py" in dispatch
  464.         response = method(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/tastypie/resources.py" in put_detail
  1428.             updated_bundle = self.obj_update(bundle=bundle, **self.remove_api_resource_names(kwargs))
File "/usr/local/lib/python2.7/dist-packages/tastypie/resources.py" in obj_update
  2163.         bundle = self.full_hydrate(bundle)
File "/usr/local/lib/python2.7/dist-packages/tastypie/resources.py" in full_hydrate
  896.                 value = field_object.hydrate(bundle)
File "/usr/local/lib/python2.7/dist-packages/tastypie/fields.py" in hydrate
  740.         return self.build_related_resource(value, request=bundle.request)
File "/usr/local/lib/python2.7/dist-packages/tastypie/fields.py" in build_related_resource
  664.             return self.resource_from_data(self.fk_resource, value, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/tastypie/fields.py" in resource_from_data
  593.         data = dict_strip_unicode_keys(data)
File "/usr/local/lib/python2.7/dist-packages/tastypie/utils/dict.py" in dict_strip_unicode_keys
  16.     for key, value in uni_dict.items():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/related.py" in __call__
  843.             manager = getattr(self.model, kwargs.pop('manager'))

Exception Type: KeyError
Exception Value: u'manager'
Reply all
Reply to author
Forward
0 new messages