From d4e0c5ca86406904d72c4bf3555e1fb00e2fa332 Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Wed, 11 Oct 2023 00:08:26 -0500 Subject: [PATCH] Fix register --- judge/models/profile.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/judge/models/profile.py b/judge/models/profile.py index 9f7b931..00dbe3f 100644 --- a/judge/models/profile.py +++ b/judge/models/profile.py @@ -12,6 +12,8 @@ from django.utils.timezone import now from django.utils.translation import gettext_lazy as _ from django.dispatch import receiver from django.db.models.signals import post_save, pre_save +from django.core.exceptions import RelatedObjectDoesNotExist + from fernet_fields import EncryptedCharField from sortedm2m.fields import SortedManyToManyField @@ -544,10 +546,11 @@ class OrganizationProfile(models.Model): @receiver([post_save], sender=User) def on_user_save(sender, instance, **kwargs): - if instance.id is None: - return - profile = instance.profile - profile._get_basic_info.dirty(profile) + try: + profile = instance.profile + profile._get_basic_info.dirty(profile) + except RelatedObjectDoesNotExist: + pass @receiver([pre_save], sender=Profile)