Python 对Tastypie API的POST请求出错

Python 对Tastypie API的POST请求出错,python,django,django-south,tastypie,Python,Django,Django South,Tastypie,当我向Tastypie API发出POST请求时,会出现以下错误: {"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,

当我向Tastypie API发出POST请求时,会出现以下错误:

{"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"}

如何理解此错误?

理解django回溯的最佳方法是从底部开始,然后向上移动,直到找到属于您的代码。一般来说,django非常可靠,问题通常是您正在做的事情:

文件\“/home/kelp/webapps/goals/goals/main/api.py\”,第191行,在 obj_create\n bundle=super(JoinedGoalResource,self)。obj_create(bundle, 请求,用户=请求。用户)

最有可能的情况是,您正在传递对create的引用,而create试图解析对象上坏的外键关系

我无法从您发布的内容中看到它,但您可以查看回溯中的最后一个条目,查看它正在查看的对象以及它正在访问的不存在的关系。提示是这与bundle对象和坏字段有关