From 2823d02763faad39b68d418295da865b13c000c5 Mon Sep 17 00:00:00 2001 From: BaiJiangjie Date: Tue, 24 Apr 2018 16:15:04 +0800 Subject: [PATCH] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E5=A4=8D=E8=B5=84=E4=BA=A7?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=AF=BC=E5=85=A5=EF=BC=8C=E8=B5=84=E4=BA=A7?= =?UTF-8?q?id=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/views/asset.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/assets/views/asset.py b/apps/assets/views/asset.py index 306a26a0a..273323193 100644 --- a/apps/assets/views/asset.py +++ b/apps/assets/views/asset.py @@ -304,7 +304,10 @@ class BulkImportAssetView(AdminUserRequiredMixin, JSONResponseMixin, FormView): if v != '': asset_dict[k] = v - asset = get_object_or_none(Asset, id=asset_dict.pop('id', 0)) + asset = None + asset_id = asset_dict.pop('id', None) + if asset_id: + asset = get_object_or_none(Asset, id=asset_id) if not asset: try: if len(Asset.objects.filter(hostname=asset_dict.get('hostname'))):