tastypie:从另一个不相关的资源中更新资源

时间:2013-07-30 17:19:20

标签: django resources tastypie

我是tastypie的新手,我想从另一个资源中更新不相关的资源; 用例:我创建了一个用户,之后我想用我从当前请求获得的值更新另一个表(资源):

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

有任何帮助吗?谢谢!

0 个答案:

没有答案