我是新来的美味派,我想从另一个资源中更新一个不相关的资源;用例:我创建了一个用户,之后我想用从当前请求中获得的值更新另一个表(资源):
class UserResource(ModelResource):
class Meta:
...
def obj_create(self, bundle, **kwargs):
bundle.data[ 'is_active' ] = 0
bundle.data[ 'is_staff' ] = 0
bundle = super( UserResource, self ).obj_create( bundle, **kwargs )
bundle.obj.set_password( sPassword )
bundle.obj.save()
# here I want to set a flag in an already existing but unrelated resource
# sg like : Fancy.obj_update( -> set flag = 2 where token = bundle.data[ 'token' ] )
# I guess its a question how the "bundle" looks like, right?
return bundle
有什么帮助吗?谢谢!