Created
September 2, 2014 02:58
-
-
Save NekoTashi/a93a378a4bc9739e0980 to your computer and use it in GitHub Desktop.
Genera un nombre de usuario de forma random y verifica si existe antes de retornarlo
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
def GenerateUsername(): | |
username = str(random.randint(0,1000000)) | |
try: | |
User.objects.get(username=username) | |
return GenerateUsername() | |
except User.DoesNotExist: | |
return username; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment