pytask/utils.py
changeset 69 c6bca38c1cbf
parent 15 beb830b0e744
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pytask/utils.py	Sat Jan 08 11:20:57 2011 +0530
@@ -0,0 +1,13 @@
+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
+