mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-03 00:15:20 +00:00
fix: 修复生成假数据脚本错误
This commit is contained in:
@@ -65,13 +65,9 @@ class AssetsGenerator(FakeDataGenerator):
|
||||
self.nodes_id = list(Node.objects.all().values_list('id', flat=True))
|
||||
|
||||
def set_assets_nodes(self, assets):
|
||||
assets_id = [asset.id for asset in assets]
|
||||
objs = []
|
||||
for asset_id in assets_id:
|
||||
for asset in assets:
|
||||
nodes_id_add_to = random.sample(self.nodes_id, 3)
|
||||
objs_add = [Asset.nodes.through(asset_id=asset_id, node_id=nid) for nid in nodes_id_add_to]
|
||||
objs.extend(objs_add)
|
||||
Asset.nodes.through.objects.bulk_create(objs, ignore_conflicts=True)
|
||||
asset.nodes.add(*nodes_id_add_to)
|
||||
|
||||
def do_generate(self, batch, batch_size):
|
||||
assets = []
|
||||
|
Reference in New Issue
Block a user