Using the following resource class, I am creating an API to list all the favorite merchants for a given user.
Category Favorites MerchantResource (ModelResource): 'Get all the merchants associated with the given user' 'user = fields.ForeignKey (UserResource,' user ', null = true, full = True) merchant = fields.ForeignKey (MerchantResource, 'Merchant', null = True, full = True) Square Meta: queryset = FavoriteMerchant.objects.all () resource_name = 'fm' include_resource_uri = Invalid permission Ed_methods = ['get '] Filtering = {' User ': ALL_WITH_RELATIONS}
Now I want to exclude user details from the API response, but user name Wants to use) field would result to filter.
FYI I tried to add the field after exiting, but still in response is the result of user details:
excludes = ['user']
You can override the
dehydration
function and remove the user from the bundle Def dehydrates (self, Bundle): Dell Bundle data ['user'] return bundle >div>
No comments:
Post a Comment