[Answered ]-Django 'User' object has no attribute 'userprofile' but instance is still created

1👍

It happens, because you set related_name='profile' and then you call it with instance.userprofile.save(). Change it to:

@receiver(post_save, sender=User)
def save_user_profile(sender, instance, **kwargs):
    instance.profile.save()

and it should work smoothly 🙂

Leave a comment