Last active
December 12, 2015 05:58
-
-
Save emperorcezar/4725313 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Try and generate a unique username. Hopefully they never see this. | |
for count in itertools.count(1): | |
# Get the first part of the email and use 30 characters | |
username = request.POST['email'].split('@')[0][:30] | |
if not User.objects.filter(username = username).exists(): | |
break | |
else: | |
# Try and append a number in the last postion of the username | |
username = username[:30-len(str(count))] + str(count) | |
continue | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment