code: def validate_username_for_new_account(person, username):
      
  
      # This is much the same as validate_username_for_new_person, except
      # we don't care if the username is used by the person owning the account
  
      # is the username valid?
  
      validate_username(username)
  
      # Check for existing people
  
      query = Person.objects.filter(username__exact=username)
      count = query.exclude(pk=person.pk).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 not belonging to this person
  
      query = Account.objects.filter(username__exact=username)
      count = query.exclude(person__pk=person.pk).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 datastore, in case username created outside Karaage.
      # Make sure we don't count the entry for person.
  
      query = Person.objects.filter(username__exact=username)
      count = query.filter(pk=person.pk).count()
      if count == 0 and account_exists(username):
          raise UsernameTaken(
              six.u('Username is already in external personal datastore.'))
docs: Validate the new username for a new account. If the username is invalid
      or in use, raises :py:exc:`UsernameInvalid` or :py:exc:`UsernameTaken`.
  
      :param person: Owner of new account.
      :param username: Username to validate.