From ccd6b01020c3f706bb3eca1f4151fa1e107f1510 Mon Sep 17 00:00:00 2001 From: "Jiangjie.Bai" Date: Wed, 17 Aug 2022 18:33:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E4=BB=85=E5=85=81=E8=AE=B8=E5=B7=B2=E5=AD=98=E5=9C=A8=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=99=BB=E5=BD=95=E5=B9=B6=E4=B8=94=E6=98=AF=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E6=96=B9=E7=94=A8=E6=88=B7=E8=AE=A4=E8=AF=81=E6=97=B6?= =?UTF-8?q?=E6=8A=A5=E9=94=99instance=E6=B2=A1=E6=9C=89id=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/orgs/signal_handlers/common.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/orgs/signal_handlers/common.py b/apps/orgs/signal_handlers/common.py index 48576a828..876613ba1 100644 --- a/apps/orgs/signal_handlers/common.py +++ b/apps/orgs/signal_handlers/common.py @@ -147,6 +147,9 @@ def _clear_users_from_org(org, users): @receiver(post_save, sender=User) @on_transaction_commit def on_user_created_set_default_org(sender, instance, created, **kwargs): + if not instance.id: + # 用户已被手动删除,instance.orgs 时会使用 id 进行查找报错,所以判断不存在id时不做处理 + return if not created: return if instance.orgs.count() > 0: