pytask/utils.py
changeset 69 c6bca38c1cbf
parent 15 beb830b0e744
equal deleted inserted replaced
68:5ff1fc726848 69:c6bca38c1cbf
       
     1 import string,random
       
     2 
       
     3 def make_key(model_name):
       
     4     """ return a 10 character random key.
       
     5     """
       
     6 
       
     7     while True:
       
     8         key = ''.join([ random.choice(string.uppercase+string.digits) for i in range(10)])
       
     9         try:
       
    10             model_name.objects.get(uniq_key=key)
       
    11         except model_name.DoesNotExist:
       
    12             return key
       
    13