from django.db import models from pingcap_sso.validators.phone import PhoneNumberValidator class BusinessDownloadLeads(models.Model): name = models.CharField(max_length=64, null=False, blank=False) company = models.CharField(max_length=255, null=False, blank=False) phone = models.CharField( max_length=32, null=False, blank=False, validators=(PhoneNumberValidator(),)) email = models.EmailField(blank=False, null=False) user_agent = models.CharField(max_length=255, blank=True, null=True) ip = models.CharField(max_length=255, blank=True, null=True) created_at = models.DateTimeField(auto_now_add=True) class Meta: db_table = 'business_download_leads' def save(self, *args, **kwargs): if self.user_agent: self.user_agent = str(self.user_agent)[:255] super(BusinessDownloadLeads, self).save(*args, **kwargs)