diff messages/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/messages/models.py	Sat Jan 04 21:34:31 2025 -0600
+++ b/messages/models.py	Wed Jan 22 17:58:16 2025 -0600
@@ -32,8 +32,10 @@
 
 class Message(models.Model):
     """The Message is a model for a private message between users."""
-    sender = models.ForeignKey(User, related_name='sender')
-    receiver = models.ForeignKey(User, related_name='receiver')
+    sender = models.ForeignKey(User, related_name='sender',
+                               on_delete=models.CASCADE)
+    receiver = models.ForeignKey(User, related_name='receiver',
+                                 on_delete=models.CASCADE)
     send_date = models.DateTimeField('Date Sent', null=True, blank=True)
     read_date = models.DateTimeField('Date Received', null=True, blank=True)
     reply_date = models.DateTimeField('Date Replied', null=True, blank=True)
@@ -91,7 +93,7 @@
 
 class Options(models.Model):
     """Options is a model for user private message options."""
-    user = models.ForeignKey(User, editable=False)
+    user = models.ForeignKey(User, editable=False, on_delete=models.CASCADE)
     attach_signature = models.BooleanField("Always attach signature?", default=True)
     notify_email = models.BooleanField("Notify me of new messages via email?", default=False)
 
@@ -109,7 +111,7 @@
     has flagged the message for spam or abuse.
 
     """
-    message = models.OneToOneField(Message)
+    message = models.OneToOneField(Message, on_delete=models.CASCADE)
     flag_date = models.DateTimeField()
     comments = models.TextField(blank=True)