From 8328edd69c792384fccda0a503779d155463d82a Mon Sep 17 00:00:00 2001 From: Michael Bai Date: Mon, 23 Mar 2020 02:32:24 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9Node=20generate=20?= =?UTF-8?q?fake=E6=97=B6=E6=AD=BB=E5=BE=AA=E7=8E=AF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/models/node.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/apps/assets/models/node.py b/apps/assets/models/node.py index 2a884a6a1..1bef55dd9 100644 --- a/apps/assets/models/node.py +++ b/apps/assets/models/node.py @@ -574,14 +574,13 @@ class Node(OrgModelMixin, SomeNodesMixin, TreeMixin, FamilyMixin, FullValueMixin org = get_current_org() if not org or not org.is_real(): Organization.default().change_to() - i = 0 - while i < count: - nodes = list(cls.objects.all()) - if count > 100: - length = 100 - else: - length = count + nodes = list(cls.objects.all()) + if count > 100: + length = 100 + else: + length = count - for i in range(length): - node = random.choice(nodes) - node.create_child('Node {}'.format(i)) + for i in range(length): + node = random.choice(nodes) + child = node.create_child('Node {}'.format(i)) + print("{}. {}".format(i, child))