From cc63c956cbc2cb4f515bdfab778d783cc6e28338 Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Thu, 13 Mar 2025 16:15:26 +0800 Subject: [PATCH] fix: Delete gather account failed --- apps/audits/utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/audits/utils.py b/apps/audits/utils.py index 3618978a2..0e8361a0f 100644 --- a/apps/audits/utils.py +++ b/apps/audits/utils.py @@ -1,11 +1,12 @@ import copy from datetime import datetime -from itertools import chain from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation +from django.core.exceptions import ObjectDoesNotExist from django.db import models from django.db.models import F, Value, CharField from django.db.models.functions import Concat +from itertools import chain from common.db.fields import RelatedManager from common.utils import validate_ip, get_ip_city, get_logger @@ -48,7 +49,10 @@ def _get_instance_field_value( if getattr(f, 'attname', None) in model_need_continue_fields: continue - value = getattr(instance, f.name, None) or getattr(instance, f.attname, None) + try: + value = getattr(instance, f.name, None) or getattr(instance, f.attname, None) + except ObjectDoesNotExist: + continue if not isinstance(value, (bool, int)) and not value: continue