models.py (702B) - Raw
1 from django.db import models 2 3 4 class Signup(models.Model): 5 email = models.EmailField() 6 created_at = models.DateTimeField(auto_now_add=True) 7 anonymized_ip = models.GenericIPAddressField() 8 user_agent = models.CharField(max_length=255, blank=True) 9 geoip = models.JSONField(null=True, blank=True) 10 referrer = models.CharField(max_length=255, blank=True) 11 12 class Meta: 13 constraints = [ 14 models.UniqueConstraint(name="unique_email", fields=["email"]), 15 ] 16 17 def __str__(self): 18 return self.email 19 20 def place_name(self): 21 if geoip := self.geoip: 22 return "{}, {}".format(geoip["city"], geoip["country_name"]) 23 return "??"