def process_dict(self, dct, bundle, outer_key=None): for key, value in (dct or {}).items(): updated_key = self.key_dehydrate_override().get(key, key) if updated_key != key: del dct[key] if isinstance(value, dict): dct[updated_key] = value if isinstance(value, dict): self.process_dict(value, bundle, outer_key=updated_key) else: # value is a model instance that is to be dehydrated to a resource_uri updated_model_instance = self.instance_dehydrate_override().get(updated_key, lambda x,y: value)(bundle.obj, value) # Find the resource field on the resource that matches one of these keys field = self.resolve_resource_field(*([outer_key, updated_key] if outer_key else [updated_key])) if field: field_resource = field.to_class() elif value: # Just search FootprintResource for a resource class that matches field_resource = FootprintResource.match_existing_resources(value.__class__)[0]() dct[updated_key] = field_resource.dehydrate_resource_uri(updated_model_instance) if value else None return dct