utils.py
author Nishanth Amuluru <nishanth@fossee.in>
Sat, 08 Jan 2011 01:46:33 +0530
changeset 64 4ee9a0f32f76
parent 15 beb830b0e744
permissions -rw-r--r--
Added edit_profile link

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