def generate_unique_username(txts, regex=None):
    from .account.adapter import get_adapter
    adapter = get_adapter()
    username = _generate_unique_username_base(txts, regex)
    max_length = get_username_max_length()
    i = 0
    while True:
        try:
            if i:
                pfx = str(i + 1)
            else:
                pfx = ''
            ret = username[0:max_length - len(pfx)] + pfx
            return adapter.clean_username(ret)
        except ValidationError:
            i += 1
dataset/ETHPy150Open pennersr/django-allauth/allauth/utils.py/generate_unique_username/original