utils.py
author Nishanth Amuluru <nishanth@fossee.in>
Fri, 07 Jan 2011 11:53:11 +0530
changeset 272 ee00b42e802f
parent 253 beb830b0e744
permissions -rw-r--r--
added admin urls

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