comparison downloads/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 f0ac48aa8c64
children
comparison
equal deleted inserted replaced
1205:510ef3cbf3e6 1206:02181fa5ac9d
50 50
51 51
52 class DownloadBase(models.Model): 52 class DownloadBase(models.Model):
53 """Abstract model to collect common download fields.""" 53 """Abstract model to collect common download fields."""
54 title = models.CharField(max_length=128) 54 title = models.CharField(max_length=128)
55 category = models.ForeignKey(Category) 55 category = models.ForeignKey(Category, on_delete=models.CASCADE)
56 description = models.TextField() 56 description = models.TextField()
57 html = models.TextField(blank=True) 57 html = models.TextField(blank=True)
58 file = models.FileField(upload_to=download_path) 58 file = models.FileField(upload_to=download_path)
59 user = models.ForeignKey(User) 59 user = models.ForeignKey(User, on_delete=models.CASCADE)
60 date_added = models.DateTimeField(db_index=True) 60 date_added = models.DateTimeField(db_index=True)
61 ip_address = models.GenericIPAddressField('IP Address') 61 ip_address = models.GenericIPAddressField('IP Address')
62 update_date = models.DateTimeField(db_index=True, blank=True) 62 update_date = models.DateTimeField(db_index=True, blank=True)
63 63
64 class Meta: 64 class Meta:
145 ordering = ('extension', ) 145 ordering = ('extension', )
146 146
147 147
148 class VoteRecord(models.Model): 148 class VoteRecord(models.Model):
149 """Model to record the date that a user voted on a download.""" 149 """Model to record the date that a user voted on a download."""
150 download = models.ForeignKey(Download) 150 download = models.ForeignKey(Download, on_delete=models.CASCADE)
151 user = models.ForeignKey(User) 151 user = models.ForeignKey(User, on_delete=models.CASCADE)
152 vote_date = models.DateTimeField(auto_now_add=True) 152 vote_date = models.DateTimeField(auto_now_add=True)
153 153
154 def __unicode__(self): 154 def __unicode__(self):
155 return u"%s voted on '%s' on %s" % ( 155 return u"%s voted on '%s' on %s" % (
156 self.user.username, 156 self.user.username,