def get_profile(user):
 if hasattr(user, '_cached_userman_profile'):
  return user._cached_userman_profile
 else:
  try:
   profile = UserProfile.objects.get(user=user)
  except UserProfile.DoesNotExist as e:
   profile = create_profile_for_user(user)
  user._cached_userman_profile = profile
  return profile

def get_profile ( user ) : if hasattr ( user , '_cached_userman_profile' ) : return user . _cached_userman_profile else : try : profile = UserProfile . objects . get ( user = user ) except UserProfile . DoesNotExist as e : profile = create_profile_for_user ( user ) user . _cached_userman_profile = profile return profile
get profile .