I get the following error when I do a POST request to the Tastypie API:
{"error_message": "", "traceback": "Traceback (most recent call last):\n\n File \"/home/kelp/lib/python2.7/django_tastypie-0.9.11-py2.7.egg/tastypie/resources.py\", line 195, in wrapper\n response = callback(request, *args, **kwargs)\n\n File \"/home/kelp/lib/python2.7/django_tastypie-0.9.11-py2.7.egg/tastypie/resources.py\", line 407, in dispatch_list\n return self.dispatch('list', request, **kwargs)\n\n File \"/home/kelp/lib/python2.7/django_tastypie-0.9.11-py2.7.egg/tastypie/resources.py\", line 436, in dispatch\n response = method(request, **kwargs)\n\n File \"/home/kelp/lib/python2.7/django_tastypie-0.9.11-py2.7.egg/tastypie/resources.py\", line 1194, in post_list\n updated_bundle = self.obj_create(bundle, request=request, **self.remove_api_resource_names(kwargs))\n\n File \"/home/kelp/webapps/goals/goals/main/api.py\", line 191, in obj_create\n bundle = super(JoinedGoalResource, self).obj_create(bundle, request, user=request.user)\n\n File \"/home/kelp/lib/python2.7/django_tastypie-0.9.11-py2.7.egg/tastypie/resources.py\", line 1839, in obj_create\n bundle = self.full_hydrate(bundle)\n\n File \"/home/kelp/lib/python2.7/django_tastypie-0.9.11-py2.7.egg/tastypie/resources.py\", line 716, in full_hydrate\n value = field_object.hydrate(bundle)\n\n File \"/home/kelp/lib/python2.7/django_tastypie-0.9.11-py2.7.egg/tastypie/fields.py\", line 643, in hydrate\n value = super(ToOneField, self).hydrate(bundle)\n\n File \"/home/kelp/lib/python2.7/django_tastypie-0.9.11-py2.7.egg/tastypie/fields.py\", line 152, in hydrate\n elif self.attribute and getattr(bundle.obj, self.attribute, None):\n\n File \"/home/kelp/webapps/goals/lib/python2.7/django/db/models/fields/related.py\", line 301, in __get__\n raise self.field.rel.to.DoesNotExist\n\nDoesNotExist\n"}
How do I make sense of this error?
The best way to make sense of the django tracebacks is to start at the bottom and move up until you get to some code that is yours. Generally django is pretty solid and usually the problem is something you are doing:
Most likely you are passing a reference to the create and its trying to resolve a foreign key relation on the object that is bad.
I cant see it from what you posted, but you can look at that last entry in the traceback and see what object it was looking at and what relation it was accessing that does not exist. The hint is that its something to do with your bundle object and a bad field.