pytask/utils.py
author Nishanth Amuluru <nishanth@fossee.in>
Tue, 11 Jan 2011 16:51:07 +0530
changeset 144 daca865314e7
parent 69 c6bca38c1cbf
permissions -rw-r--r--
view_work is now working

import string,random

def make_key(model_name):
    """ return a 10 character random key.
    """

    while True:
        key = ''.join([ random.choice(string.uppercase+string.digits) for i in range(10)])
        try:
            model_name.objects.get(uniq_key=key)
        except model_name.DoesNotExist:
            return key