Django-Tastypie:“;错误消息:&引用';布尔';对象没有属性';阅读'&引用;
我正在使用Backbone.js+Tastypie+Django并尝试使用patch=true保存模型以更新模型上的点,如Django-Tastypie:“;错误消息:&引用';布尔';对象没有属性';阅读'&引用;,django,rest,backbone.js,tastypie,Django,Rest,Backbone.js,Tastypie,我正在使用Backbone.js+Tastypie+Django并尝试使用patch=true保存模型以更新模型上的点,如 this.save({ points: newPoints }, { patch: true }); 这将发出一个PUT请求,因为它应该与请求负载一起发出 points: 105 但是,我收到一条500错误消息 {"error_message": "'bool' object has no attribute 'read'", "traceback": "Tra
this.save({
points: newPoints
}, {
patch: true
});
这将发出一个PUT请求,因为它应该与请求负载一起发出
points: 105
但是,我收到一条500错误消息
{"error_message": "'bool' object has no attribute 'read'", "traceback": "Traceback (most recent call last):
File \"/Users/me/.virtualenvs/project/lib/python2.7/site-packages/tastypie/resources.py\", line 217, in wrapper
response = callback(request, *args, **kwargs)
File \"/Users/me/.virtualenvs/project/lib/python2.7/site-packages/tastypie/resources.py\", line 468, in dispatch_detail
return self.dispatch('detail', request, **kwargs)
File \"/Users/me/.virtualenvs/project/lib/python2.7/site-packages/tastypie/resources.py\", line 491, in dispatch
response = method(request, **kwargs)
File \"/Users/me/.virtualenvs/project/lib/python2.7/site-packages/tastypie/resources.py\", line 1656, in patch_detail
self.update_in_place(request, bundle, deserialized)
File \"/Users/me/.virtualenvs/project/lib/python2.7/site-packages/tastypie/resources.py\", line 1679, in update_in_place
return self.obj_update(bundle=original_bundle, **kwargs)
File \"/Users/me/.virtualenvs/project/lib/python2.7/site-packages/tastypie/resources.py\", line 2209, in obj_update
bundle = self.full_hydrate(bundle)
File \"/Users/me/.virtualenvs/project/lib/python2.7/site-packages/tastypie/resources.py\", line 909, in full_hydrate
value = field_object.hydrate(bundle)
File \"/Users/me/.virtualenvs/project/lib/python2.7/site-packages/tastypie/fields.py\", line 382, in hydrate
value = make_aware(parse(value))
File \"/Users/me/.virtualenvs/project/lib/python2.7/site-packages/dateutil/parser.py\", line 720, in parse
return DEFAULTPARSER.parse(timestr, **kwargs)
File \"/Users/me/.virtualenvs/project/lib/python2.7/site-packages/dateutil/parser.py\", line 308, in parse
res = self._parse(timestr, **kwargs)
File \"/Users/me/.virtualenvs/project/lib/python2.7/site-packages/dateutil/parser.py\", line 356, in _parse
l = _timelex.split(timestr)
File \"/Users/me/.virtualenvs/project/lib/python2.7/site-packages/dateutil/parser.py\", line 150, in split
return list(cls(s))
File \"/Users/me/.virtualenvs/project/lib/python2.7/site-packages/dateutil/parser.py\", line 147, in next
return self.__next__() # Python 2.x support
File \"/Users/me/.virtualenvs/project/lib/python2.7/site-packages/dateutil/parser.py\", line 141, in __next__
token = self.get_token()
File \"/Users/me/.virtualenvs/project/lib/python2.7/site-packages/dateutil/parser.py\", line 72, in get_token
nextchar = self.instream.read(1)
AttributeError: 'bool' object has no attribute 'read'
"}
这是我的UserProfile模型资源
class UserProfileResource(ModelResource):
"""A resource for the UserProfile model."""
class Meta:
queryset = UserProfile.objects.all()
resource_name = 'userprofile'
authorization = Authorization()
excludes = ['field_to_exclude']
always_return_data = True
有人知道如何调试这个错误吗?我有一个datetime字段,它是空的,在api调用中没有显示为datetime,而是显示为布尔值。我不确定为什么会发生这种情况,但我认为这是tastypie中的一个错误,或者我误解了有关配置的某些内容,或者两者兼而有之
我从tastypie资源中排除了此字段,并成功地将其放入模型并进行修补。这是服务器端故障。您能在处理请求的服务器上显示一些代码吗?我已经添加了我的服务器代码——我使用的是tastypie,所以我唯一的定制就是定义资源。因为它使用的是库而不是我的代码,所以我不太确定如何跟踪它