Thanks @astevanovic for pointing the right direction.
I found that overriding the dehydrate method to process only certain specified fields is a little less tedious than overriding the full_hydrate method to skip fields.
In an effort to reuse, I came up with the following code snippets. Hope this will be helpful for some:
class BeeModelResource(ModelResource): def dehydrate(self, bundle): bundle = super(BeeModelResource, self).dehydrate(bundle) bundle = self.dehydrate_partial(bundle) return bundle def dehydrate_partial(self, bundle): for field_name, resource_field in self.fields.items(): if not isinstance(resource_field, RelatedField): continue if resource_field.full:
When using the @sigmus example, resources will require 3 modifications:
- both resources will use
BeeModuleResource as their superclass (or add dehydrate_partial to one resource and dehydrate_selected to another.) - unset
full=True for any of the resources - add
partial_fields to Meta resource unset resource
`` ``
class ClientResource(BeeModelResource):
source share