from contact.models import Contact
+DEBUG_KEY = '12345'
+
class Submission(models.Model):
contact = models.ForeignKey(Contact, null = True)
key = models.CharField(max_length = 30, unique = True)
@classmethod
def generate_key(cls):
key = ''
- while not key and key in [record['key'] for record in cls.objects.values('key')]:
+ while not key or key in [record['key'] for record in cls.objects.values('key')]:
key = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for i in range(30))
return key