def alter_list_data_to_serialize(self, request, data): # Example iteration through data for item in data['object']: # Add extra object to it item.data['extra'] = 'data you want to add' # Return data return dataBe caution if you try to add extra data like this: item['extra'] = 'data you want to add', you will get error: "Bundle" objects does not support item assignment. Since item is a bundle type object, you should use Bundle.data to get access to it.
You may curious why don't I use dehydrate(self, bundle) function to do that. Because I don't know how to iterate through the bundle object.
Post a Comment