本文整理汇总了Python中models.Node.dump_bulk方法的典型用法代码示例。如果您正苦于以下问题:Python Node.dump_bulk方法的具体用法?Python Node.dump_bulk怎么用?Python Node.dump_bulk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Node
的用法示例。
在下文中一共展示了Node.dump_bulk方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit
# 需要导入模块: from models import Node [as 别名]
# 或者: from models.Node import dump_bulk [as 别名]
def edit(request, stack_id, template='stack/edit.html'):
stack = Stack.objects.get(pk=stack_id)
root = Node.objects.get(stack=stack, depth=1)
project = root.project
public_projects = Project.objects.all()
root_dump = Node.dump_bulk(parent=root)
nodes_dump = dumps(root_dump, cls=DjangoJSONEncoder)
temp_output = serializers.serialize('python', public_projects)
projects = dumps(temp_output, cls=DjangoJSONEncoder)
temp_output = serializers.serialize('python', [project])
project_json = dumps(temp_output, cls=DjangoJSONEncoder)
temp_output = serializers.serialize('python', [stack])
stack_json = dumps(temp_output, cls=DjangoJSONEncoder)
return render(request, template, {
'page': 'edit',
'stack': stack_json,
'stack_raw': stack,
'project': project_json,
'root': root,
'nodes': root_dump,
'nodes_dump': nodes_dump,
'projects': projects,
'projects_raw': public_projects,
'link_types': LINK_CHOICES,
'licenses': License.objects.all()
})
示例2: share
# 需要导入模块: from models import Node [as 别名]
# 或者: from models.Node import dump_bulk [as 别名]
def share(request, stack_id, template='stack/share.html'):
stack = Stack.objects.get(pk=stack_id)
root = Node.objects.get(stack=stack, depth=1)
project = root.project
public_projects = Project.objects.all()
root_dump = Node.dump_bulk(parent=root)
nodes_dump = dumps(root_dump, cls=DjangoJSONEncoder)
temp_output = serializers.serialize('python', public_projects)
projects = dumps(temp_output, cls=DjangoJSONEncoder)
temp_output = serializers.serialize('python', [project])
project_json = dumps(temp_output, cls=DjangoJSONEncoder)
temp_output = serializers.serialize('python', [stack])
stack_json = dumps(temp_output, cls=DjangoJSONEncoder)
temp_output = serializers.serialize('python', Contributor.objects.all())
cont_json = dumps(temp_output, cls=DjangoJSONEncoder)
width = request.GET.get('w', '')
height = request.GET.get('h', '')
return render(request, template, {
'page': 'share',
'stack': stack_json,
'stack_raw': stack,
'project': project_json,
'root': root,
'nodes': root_dump,
'nodes_dump': nodes_dump,
'projects': projects,
'contributors': cont_json,
'projects_raw': public_projects,
'link_types': LINK_CHOICES,
'licenses': License.objects.all(),
'width': width,
'height': height
})