Search code examples
pythondjangodjango-users

TypeError: Update_Profile() missing 1 required positional argument: 'self'


Whenever I am creating the superuser then it's throwing me an error Update_Profile() missing 1 required positional argument: 'self'.

@receiver(post_save, sender=User)
def Update_Profile(self, instance, created, **kwargs):
    if created:
        UserProfile.objects.create(user=instance)
    instance.user_profile.save()


Solution

  • it should be, (without self)

    @receiver(post_save, sender=User)
    def Update_Profile(instance, created, **kwargs):
    ...