Decode username back to string from bytes after encode

This commit is contained in:
PCoder 2020-03-07 11:13:57 +05:30
parent 4441ba37ca
commit e18188603a
1 changed files with 3 additions and 1 deletions

View File

@ -96,7 +96,9 @@ def assign_username(user):
# Try to come up with a username
first_name, last_name = get_first_and_last_name(user.name)
user.username = unicodedata.normalize('NFKD', first_name + last_name).encode('ascii', 'ignore')
user.username = unicodedata.normalize(
'NFKD', first_name + last_name
).encode('ascii', 'ignore').decode('ascii', 'ignore')
user.username = "".join([char for char in user.username if char.isalnum()]).lower()
if user.username.strip() == "":
try: