Hey everyone, While using the Tastypie API, I have been getting a MultipleObjectsReturned error somehow when obj_get gets called. I feed a Resource URI to a ToManyField for one of the resources and somehow I get this error. This has me really frustrated, since I thought that by giving it a URI (ex: " /api/v1/gene/1/ "), it would only return one object. Creating and saving objects works fine without the Tastypie API.
These are the involved resources: class GeneResource(ModelResource): entrezid = fields.IntegerField(attribute = 'entrezid') genesets = fields.ToManyField("genesets.api.resources.GeneSetResource", 'genesets', null=True, blank=True) class Meta: queryset = Gene.objects.all() resource_name = 'gene' filtering = {'entrezid': ALL, } class GeneSetResource(ModelResource): title = fields.CharField(attribute='title') user = fields.ForeignKey(UserResource, 'user', full=True) organism = fields.ToOneField(OrganismResource, 'organism', full=True) genes = fields.ToManyField(GeneResource, 'genes', related_name='genesets', full=True) class Meta: queryset = GeneSet.objects.all() resource_name = 'geneset' authorization = Authorization() filtering = { 'user': ALL_WITH_RELATIONS, 'title': ALL, 'genes': ALL_WITH_RELATIONS, } And this is the error I get: "Traceback (most recent call last): File "/home/rene/Documents/venv/local/lib/python2.7/site-packages/tastypie/resources.py", line 217, in wrapper response = callback(request, *args, **kwargs) File "/home/rene/Documents/venv/local/lib/python2.7/site-packages/tastypie/resources.py", line 459, in dispatch_list return self.dispatch('list', request, **kwargs) File "/home/rene/Documents/venv/local/lib/python2.7/site-packages/tastypie/resources.py", line 491, in dispatch response = method(request, **kwargs) File "/home/rene/Documents/venv/local/lib/python2.7/site-packages/tastypie/resources.py", line 1357, in post_list updated_bundle = self.obj_create(bundle, **self.remove_api_resource_names(kwargs)) File "/home/rene/Documents/venv/local/lib/python2.7/site-packages/tastypie/resources.py", line 2150, in obj_create return self.save(bundle) File "/home/rene/Documents/venv/local/lib/python2.7/site-packages/tastypie/resources.py", line 2300, in save m2m_bundle = self.hydrate_m2m(bundle) File "/home/rene/Documents/venv/local/lib/python2.7/site-packages/tastypie/resources.py", line 964, in hydrate_m2m bundle.data[field_name] = field_object.hydrate_m2m(bundle) File "/home/rene/Documents/venv/local/lib/python2.7/site-packages/tastypie/fields.py", line 853, in hydrate_m2m m2m_hydrated.append(self.build_related_resource(value, **kwargs)) File "/home/rene/Documents/venv/local/lib/python2.7/site-packages/tastypie/fields.py", line 653, in build_related_resource return self.resource_from_uri(self.fk_resource, value, **kwargs) File "/home/rene/Documents/venv/local/lib/python2.7/site-packages/tastypie/fields.py", line 573, in resource_from_uri obj = fk_resource.get_via_uri(uri, request=request) File "/home/rene/Documents/venv/local/lib/python2.7/site-packages/tastypie/resources.py", line 838, in get_via_uri return self.obj_get(bundle=bundle, **self.remove_api_resource_names(kwargs)) File "/home/rene/Documents/venv/local/lib/python2.7/site-packages/tastypie/resources.py", line 2131, in obj_get raise MultipleObjectsReturned("More than '%s' matched '%s'." % (self._meta.object_class.__name__, stringified_kwargs)) MultipleObjectsReturned: More than 'Gene' matched ''. " Any ideas of what is going on?? Thanks! Much appreciated!! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.