'How to trigger signals for User model whenever profile is updated in django?

I am using signals to create a profile whenever a user account is created. This works fine. It also updates the profile whenever the user's username is changed. The problem here is that I wanted to edit the user's first_name and last_name only when the profile is edited so I tried using signals in which the receiver is now the CustomUser model. But, I don't think I am doing it right.

# accounts/models.py

class CustomUser(AbstractUser):
    age = models.IntegerField(null=True, blank=True)
    bio = models.TextField(null=True, blank=True)
    

    class Meta:
        unique_together = [['first_name', 'last_name']]

# pages/models.py

class Profile(models.Model):
    user = models.OneToOneField(CustomUser, on_delete=models.CASCADE, blank=True, null=True)
    first_name = models.CharField(max_length=200, blank=True, null=True)
    last_name = models.CharField(max_length=200, blank=True, null=True)

# accounts/signals.py

@receiver(post_save, sender=Profile)
def update_profile(sender, instance, created, **kwargs):
    if not created:
        print("Custom user updated!")
    
# pages/signals.py

@receiver(post_save, sender=CustomUser)
def create_profile(sender, instance, created, **kwargs):
    if created:
        Profile.objects.create(user=instance)
        print("Profile created!")
    
    
@receiver(post_save, sender=CustomUser)
def update_profile(sender, instance, created, **kwargs):
    if not created:
        instance.profile.save()
        print("Profile updated!")



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source