[英]How to append success=true on django tastypie json
I am using django-tastypie to implement restapi, i am using sencha as a mobile client . 我正在使用django-tastypie实现restapi,我正在使用sencha作为移动客户端。 I need to manipulate the response text for some purpose.
我需要出于某些目的操纵响应文本。
Like below 像下面
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();
//});
}
});
I have json response as follows 我有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"}]}
It is very important to send success => true If, success is not defined or not equal to true then it will be considered as a form submit error. 发送成功=> true非常重要如果成功未定义或不等于true,则将其视为表单提交错误。 How to append success=true on django tastypie json
如何在Django Deliciouspie JSON上附加success = true
If I understand your question correctly, you want to append {'success': true}
to the result of API calls, correct? 如果我正确理解了您的问题,您想在API调用的结果后附加
{'success': true}
,对吗? If so, you can override the dehydrate method on your Resource
class: 如果是这样,则可以在
Resource
类上重写dehydrate方法:
def dehydrate(self, bundle):
bundle.data['success'] = True
return bundle
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.