[英]How to append success=true on django tastypie json
我正在使用django-tastypie实现restapi,我正在使用sencha作为移动客户端。 我需要出于某些目的操纵响应文本。
像下面
form.submit({
success: function() {
// The callback function is run when the user taps the 'ok' button
form.reset();
//Ext.Msg.alert('Thank You', 'Your message has been received', function() {
// form.reset();
//});
}
});
我有JSON响应如下
{"meta": {"limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 13},
"objects": [{"body": "This will prbbly be my lst edited post.", "id": 1,
"pub_date": "2011-05-22", "resource_uri": "/api/v1/entry/1/", "slug": "another-post",
"title": "Another Post"}, {"body": "This will prbbly be my lst post.", "id": 2,
"pub_date": "2011-05-22", "resource_uri": "/api/v1/entry/2/", "slug": "another-post",
"title": "Another Post"}, {"body": "This will prbbly be my lst edited post"}]}
发送成功=> true非常重要如果成功未定义或不等于true,则将其视为表单提交错误。 如何在Django Deliciouspie JSON上附加success = true
如果我正确理解了您的问题,您想在API调用的结果后附加{'success': true}
,对吗? 如果是这样,则可以在Resource
类上重写dehydrate方法:
def dehydrate(self, bundle):
bundle.data['success'] = True
return bundle
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.