本文整理匯總了Python中tastypie.resources.ModelResource.obj_create方法的典型用法代碼示例。如果您正苦於以下問題:Python ModelResource.obj_create方法的具體用法?Python ModelResource.obj_create怎麽用?Python ModelResource.obj_create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tastypie.resources.ModelResource
的用法示例。
在下文中一共展示了ModelResource.obj_create方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: obj_create
# 需要導入模塊: from tastypie.resources import ModelResource [as 別名]
# 或者: from tastypie.resources.ModelResource import obj_create [as 別名]
def obj_create(self, bundle, **kwargs):
try:
return ModelResource.obj_create(self, bundle, **kwargs)
except IntegrityError:
# This has the negative side-effect of always making the server
# respond with (201) regardless of whether or not the object was
# just created. It would be better if it could return (200) if the
# object already existed.
allocation_id = simplejson.loads(bundle.request.body)['allocation_id']
fileset = models.Fileset.objects.get(allocation_id=allocation_id)
bundle.obj = fileset
return bundle