本文整理汇总了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