code: def _generate_username(self):
          
          while True:
              # Generate a UUID username, removing dashes and the last 2 chars
              # to make it fit into the 30 char User.username field. Gracefully
              # handle any unlikely, but possible duplicate usernames.
              username = str(uuid.uuid4())
              username = username.replace('-', '')
              username = username[:-2]
  
              try:
                  User.objects.get(username=username)
              except User.DoesNotExist:
                  return username
docs: Generate a unique username