Untitled
unknown
plain_text
a year ago
617 B
1
Indexable
Never
class AffiliateInfo(models.Model): id = models.CharField(primary_key=True, max_length=7, editable=False) name = models.CharField(unique=True, max_length=200) date_updated = models.DateTimeField() date_created = models.DateTimeField() class Meta: managed = False db_table = 'affiliate_info' def save(self, *args, **kwargs): while not self.id: obj_id = ''.join(random.sample(string.digits + string.ascii_letters, 7)) if not AffiliateInfo.objects.filter(pk=obj_id).exists(): self.id = obj_id super().save(*args, **kwargs)