Commit 2e0107c8 authored by Akshay Karthik's avatar Akshay Karthik
Browse files

re-add loop

parent f91f0011
......@@ -37,14 +37,14 @@ class URL( models.Model ):
hashids_counter += 1
short = hashids.encrypt(hashids_counter)
tries = 1
try:
urls = URL.objects.get( short__iexact = short )
tries += 1
hashids_counter += 1
except URL.DoesNotExist:
return short
if tries > 100:
return None
while tries < 100:
try:
urls = URL.objects.get( short__iexact = short )
tries += 1
hashids_counter += 1
except URL.DoesNotExist:
return short
return None
# this needs to be here instead of at the top because the model's manager must be available before this line
hashids_counter = URL.objects.count()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment