equal
deleted
inserted
replaced
1 import string,random |
1 import string,random |
2 |
2 |
3 def make_key(): |
3 def make_key(model_name): |
4 """ return a 10 character random key. |
4 """ return a 10 character random key. |
5 """ |
5 """ |
6 |
|
7 return ''.join([ random.choice(string.uppercase+string.digits) for i in range(10)]) |
|
8 |
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 |