Skip to content

Instantly share code, notes, and snippets.

@NekoTashi
Created September 2, 2014 02:58
Show Gist options
  • Save NekoTashi/a93a378a4bc9739e0980 to your computer and use it in GitHub Desktop.
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
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