Mercurial > public > sg101
diff bio/models.py @ 1206:02181fa5ac9d modernize tip
Update to Django 1.9.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 22 Jan 2025 17:58:16 -0600 |
parents | eeaf387803c6 |
children |
line wrap: on
line diff
--- a/bio/models.py Sat Jan 04 21:34:31 2025 -0600 +++ b/bio/models.py Wed Jan 22 17:58:16 2025 -0600 @@ -80,7 +80,8 @@ class UserProfile(models.Model): """model to represent additional information about users""" - user = models.OneToOneField(User, related_name='profile') + user = models.OneToOneField(User, related_name='profile', + on_delete=models.CASCADE) location = models.CharField(max_length=128, blank=True) country = models.CharField(max_length=2, blank=True, default='', choices=bio.flags.FLAG_CHOICES, @@ -184,8 +185,8 @@ class UserProfileFlag(models.Model): """This model represents a user flagging a profile as inappropriate.""" - user = models.ForeignKey(User) - profile = models.ForeignKey(UserProfile) + user = models.ForeignKey(User, on_delete=models.CASCADE) + profile = models.ForeignKey(UserProfile, on_delete=models.CASCADE) flag_date = models.DateTimeField(auto_now_add=True) def __unicode__(self): @@ -202,8 +203,8 @@ class BadgeOwnership(models.Model): """This model represents the ownership of badges by users.""" - profile = models.ForeignKey(UserProfile) - badge = models.ForeignKey(Badge) + profile = models.ForeignKey(UserProfile, on_delete=models.CASCADE) + badge = models.ForeignKey(Badge, on_delete=models.CASCADE) count = models.IntegerField(default=1) class Meta: