def _get_user_and_profile(username):
 try:
  existing_user = User.objects.get(username=username)
  existing_user_profile = UserProfile.objects.get(user=existing_user)
 except ObjectDoesNotExist:
  raise UserNotFound()
 return (existing_user, existing_user_profile)

def _get_user_and_profile ( username ) : try : existing_user = User . objects . get ( username = username ) existing_user_profile = UserProfile . objects . get ( user = existing_user ) except ObjectDoesNotExist : raise UserNotFound ( ) return ( existing_user , existing_user_profile )
helper method to return the legacy user and profile objects based on username .