本文整理匯總了Python中tastypie.resources.ModelResource.full_dehydrate方法的典型用法代碼示例。如果您正苦於以下問題:Python ModelResource.full_dehydrate方法的具體用法?Python ModelResource.full_dehydrate怎麽用?Python ModelResource.full_dehydrate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tastypie.resources.ModelResource
的用法示例。
在下文中一共展示了ModelResource.full_dehydrate方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: bundleItemCollection
# 需要導入模塊: from tastypie.resources import ModelResource [as 別名]
# 或者: from tastypie.resources.ModelResource import full_dehydrate [as 別名]
def bundleItemCollection(modelResource, request, items):
item_list = []
for item in items:
bundle = ModelResource.build_bundle(modelResource, obj=item, request=request)
bundle = ModelResource.full_dehydrate(modelResource, bundle)
item_list.append(bundle)
return item_list;
示例2: full_dehydrate
# 需要導入模塊: from tastypie.resources import ModelResource [as 別名]
# 或者: from tastypie.resources.ModelResource import full_dehydrate [as 別名]
def full_dehydrate(self, bundle, for_list=False):
bundle = ModelResource.full_dehydrate(self, bundle, for_list=for_list)
bundle.related_obj = self
if for_list is True:
fk = fields.ForeignKey(I4pProjectListResource, attribute="master", full=True)
bundle.data["project"] = fk.dehydrate(bundle)
return bundle
示例3: full_dehydrate
# 需要導入模塊: from tastypie.resources import ModelResource [as 別名]
# 或者: from tastypie.resources.ModelResource import full_dehydrate [as 別名]
def full_dehydrate(self, bundle, for_list=False):
bundle = ModelResource.full_dehydrate(self, bundle, for_list)
if bundle.obj.picture:
thumbnailer = get_thumbnailer(bundle.obj.picture)
thumbnail_options = {'size': (ResizeThumbApi.width, ResizeThumbApi.height)}
bundle.data["thumb"] = thumbnailer.get_thumbnail(thumbnail_options).url
else:
bundle.data["thumb"] = None
if for_list is False:
bundle.data["tags"] = [tag.name for tag in Tag.objects.get_for_object(bundle.obj)]
if(bundle.obj.picture):
thumbnail_options = {'size': (ResizeDisplay.width, ResizeDisplay.width)}
bundle.data["image"] = thumbnailer.get_thumbnail(thumbnail_options).url
else:
bundle.data["image"] = None
try:
bundle.data["article"] = Article.get_for_object(bundle.obj).render()
except ArticleForObject.DoesNotExist:
bundle.data["article"] = None
return bundle