From 023ca297527aa676eb4624ac268c75395ab1b2ba Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 1 Feb 2023 12:39:38 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=88=9B=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/audits/utils.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/apps/audits/utils.py b/apps/audits/utils.py index 6f8f9e730..3ff42177c 100644 --- a/apps/audits/utils.py +++ b/apps/audits/utils.py @@ -1,17 +1,14 @@ -import csv import codecs - +import csv from itertools import chain -from django.http import HttpResponse from django.db import models +from django.http import HttpResponse -from settings.serializers import SettingsSerializer from common.utils import validate_ip, get_ip_city, get_logger -from common.db import fields +from settings.serializers import SettingsSerializer from .const import DEFAULT_CITY - logger = get_logger(__name__) @@ -95,7 +92,7 @@ def _get_instance_field_value( def model_to_dict_for_operate_log( - instance, include_model_fields=True, include_related_fields=True + instance, include_model_fields=True, include_related_fields=False ): model_need_continue_fields = ['date_updated'] m2m_need_continue_fields = ['history_passwords'] @@ -106,7 +103,7 @@ def model_to_dict_for_operate_log( if include_related_fields: opts = instance._meta - for f in chain(opts.many_to_many, opts.related_objects): + for f in opts.many_to_many: value = [] if instance.pk is not None: related_name = getattr(f, 'attname', '') or getattr(f, 'related_name', '')