2013-01-13 45 views

回答

-1

是的。您必須重寫obj_create()定義。這裏有一個例子

def obj_create(self, bundle, request=None, **kwargs): 
    bundle = self.full_hydrate(bundle) 
    attempt = Attempt.objects.filter(**kwargs) 
    if attempt.count() < 1: 
     bundle.obj = Attempt(*kwargs) 
    else: 
     logger.info("Updating attempt") 
     bundle.obj = attempt[0] 
    return bundle