code: def validate_username_for_new_person(username):
      
  
      # is the username valid?
  
      validate_username(username)
  
      # Check for existing people
  
      count = Person.objects.filter(username__exact=username).count()
      if count >= 1:
          raise UsernameTaken(six.u(
              'The username is already taken. Please choose another. '
              'If this was the name of your old account please email %s')
              % settings.ACCOUNTS_EMAIL)
  
      # Check for existing accounts
  
      count = Account.objects.filter(username__exact=username).count()
      if count >= 1:
          raise UsernameTaken(six.u(
              'The username is already taken. Please choose another. '
              'If this was the name of your old account please email %s')
              % settings.ACCOUNTS_EMAIL)
  
      # Check account datastore, in case username created outside Karaage.
  
      if account_exists(username):
          raise UsernameTaken(
              six.u('Username is already in external account datastore.'))
  
      return username
docs: Validate the new username for a new person. If the username is invalid
      or in use, raises :py:exc:`UsernameInvalid` or :py:exc:`UsernameTaken`.
  
      :param username: Username to validate.