From d0e56a17d6fe129c6b5f52cb06a6c4f185dddf1a Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 9 Feb 2023 18:37:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=AE=A1=E8=AE=A1?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E4=BF=9D=E5=AD=98=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/audits/backends/db.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/audits/backends/db.py b/apps/audits/backends/db.py index b24efaaa4..aa60b3569 100644 --- a/apps/audits/backends/db.py +++ b/apps/audits/backends/db.py @@ -69,6 +69,12 @@ class OperateLogStore(object): before.update(op_before) after.update(op_after) else: + # 限制长度 128 OperateLog.resource.field.max_length + max_length = 128 + resource = kwargs.get('resource', '') + if isinstance(resource, str) and (len(resource) > max_length): + # 截取字符串 + kwargs.update({'resource': resource[:max_length]}) op_log = self.model(**kwargs) diff = self.convert_before_after_to_diff(before, after)