From 70055b8af276a7ca5367370fdbe7e90f1f1b57e2 Mon Sep 17 00:00:00 2001 From: Bai Date: Mon, 17 May 2021 16:10:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dremoteapp=E8=8E=B7?= =?UTF-8?q?=E5=8F=96asset=5Finfo=E5=A4=B1=E8=B4=A5=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 --- .../serializers/attrs/application_category/remote_app.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/applications/serializers/attrs/application_category/remote_app.py b/apps/applications/serializers/attrs/application_category/remote_app.py index 9fa691976..3cda4ac1e 100644 --- a/apps/applications/serializers/attrs/application_category/remote_app.py +++ b/apps/applications/serializers/attrs/application_category/remote_app.py @@ -39,14 +39,14 @@ class RemoteAppSerializer(serializers.Serializer): @staticmethod def get_asset_info(obj): asset_id = obj.get('asset') - if not asset_id or is_uuid(asset_id): + if not asset_id or not is_uuid(asset_id): return {} try: - asset = Asset.objects.filter(id=str(asset_id)).values_list('id', 'hostname') + asset = Asset.objects.get(id=str(asset_id)) except ObjectDoesNotExist as e: logger.error(e) return {} if not asset: return {} - asset_info = {'id': str(asset[0]), 'hostname': asset[1]} + asset_info = {'id': str(asset.id), 'hostname': asset.hostname} return asset_info