Reputation: 15464
I am using django-tastypie to implement restapi, i am using sencha as a mobile client . 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
{"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. How to append success=true on django tastypie json
Upvotes: 2
Views: 837
Reputation: 6968
If I understand your question correctly, you want to append {'success': true}
to the result of API calls, correct? If so, you can override the dehydrate method on your Resource
class:
def dehydrate(self, bundle):
bundle.data['success'] = True
return bundle
Upvotes: 1