From 345c1c11e986941ac5ec53592b0727302370ed5a Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Tue, 4 Jun 2024 09:34:50 -0400 Subject: [PATCH] Guard against the role field not being populated when doing the final reset of Role.implicit_parents. --- tools/scripts/ig-hotfix/role_check.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/scripts/ig-hotfix/role_check.py b/tools/scripts/ig-hotfix/role_check.py index 3cc1b7933b..ef2e67b9c0 100644 --- a/tools/scripts/ig-hotfix/role_check.py +++ b/tools/scripts/ig-hotfix/role_check.py @@ -180,6 +180,7 @@ print(" role_fields = [f for f in cls._meta.fields if isinstance(f, ImplicitR print(" obj = cls.objects.get(id=obj_id)") print(" for f in role_fields:") print(" r = getattr(obj, f.name, None)") -print(" r.implicit_parents = '[]'") -print(" r.save()") +print(" if r is not None:") +print(" r.implicit_parents = '[]'") +print(" r.save()") print(" obj.save()")