diff 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
line wrap: on
line diff
--- a/downloads/models.py	Sat Jan 04 21:34:31 2025 -0600
+++ b/downloads/models.py	Wed Jan 22 17:58:16 2025 -0600
@@ -52,11 +52,11 @@
 class DownloadBase(models.Model):
     """Abstract model to collect common download fields."""
     title = models.CharField(max_length=128)
-    category = models.ForeignKey(Category)
+    category = models.ForeignKey(Category, on_delete=models.CASCADE)
     description = models.TextField()
     html = models.TextField(blank=True)
     file = models.FileField(upload_to=download_path)
-    user = models.ForeignKey(User)
+    user = models.ForeignKey(User, on_delete=models.CASCADE)
     date_added = models.DateTimeField(db_index=True)
     ip_address = models.GenericIPAddressField('IP Address')
     update_date = models.DateTimeField(db_index=True, blank=True)
@@ -147,8 +147,8 @@
 
 class VoteRecord(models.Model):
     """Model to record the date that a user voted on a download."""
-    download = models.ForeignKey(Download)
-    user = models.ForeignKey(User)
+    download = models.ForeignKey(Download, on_delete=models.CASCADE)
+    user = models.ForeignKey(User, on_delete=models.CASCADE)
     vote_date = models.DateTimeField(auto_now_add=True)
 
     def __unicode__(self):