(sender, **kwargs)
Creates a UserProfile if a User doesn't have one
Creates a UserProfile if a User doesn't have one
Creates a UserProfile if a User doesn t have one
def create_missing_profile(sender, **kwargs):
    """Creates a UserProfile if a User doesn't have one"""
    user = kwargs["instance"]

    if not hasattr(user, "profile"):
        UserProfile = apps.get_model("users.UserProfile")
        profile = UserProfile.objects.create(user=user)
        user.profile = profile
def create_missing_profile ( sender , * * kwargs ) : user = kwargs [ "instance" ] if not hasattr ( user , "profile" ) : UserProfile = apps . get_model ( "users.UserProfile" ) profile = UserProfile . objects . create ( user = user ) user . profile = profile