- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
# Generate a unique username from the first part of the email address
base_name = email.split('@')[0][:25]
if User.objects.filter(username=base_name).count() == 0:
username = base_name
else:
for ii in range(1, 99999+1):
if User.objects.filter( username = base_name + str(ii) ).count() == 0:
username = email.split('@')[0][:25] + str(ii)
break