Is there any possible way to override the sync method for PUT response and exclude the id field from db, and remaining the same? I am using the Django REST framework for APIs; while trying to PUT, I'm getting:
{"field_errors": "id": ["This field does not exist."],}
I think if I override sync and exclude the id field for PUT, my problem will be solved, but I don't know how to do it.
Backbone._sync = Backbone.sync;
Backbone.sync = function(method, model, options) {
var params = _.clone(options);
delete model.attributes.id;
params.success = function(model) {
if(options.success) options.success(model);
};
params.error = function(model) {
if(options.error) options.error(model);
};
Backbone._sync(method, model, params);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With