1212# need to extend from the user model, so just create a separate
1313# class.
1414class Committer (models .Model ):
15- user = models .OneToOneField (User , null = False , blank = False , primary_key = True )
15+ user = models .OneToOneField (User , null = False , blank = False , primary_key = True , on_delete = models . CASCADE )
1616 active = models .BooleanField (null = False , blank = False , default = True )
1717
1818 def __str__ (self ):
@@ -87,7 +87,7 @@ def __str__(self):
8787
8888class Patch (models .Model , DiffableModel ):
8989 name = models .CharField (max_length = 500 , blank = False , null = False , verbose_name = 'Description' )
90- topic = models .ForeignKey (Topic , blank = False , null = False )
90+ topic = models .ForeignKey (Topic , blank = False , null = False , on_delete = models . CASCADE )
9191
9292 # One patch can be in multiple commitfests, if it has history
9393 commitfests = models .ManyToManyField (CommitFest , through = 'PatchOnCommitFest' )
@@ -99,12 +99,12 @@ class Patch(models.Model, DiffableModel):
9999 gitlink = models .URLField (blank = True , null = False , default = '' )
100100
101101 # Version targeted by this patch
102- targetversion = models .ForeignKey (TargetVersion , blank = True , null = True , verbose_name = "Target version" )
102+ targetversion = models .ForeignKey (TargetVersion , blank = True , null = True , verbose_name = "Target version" , on_delete = models . CASCADE )
103103
104104 authors = models .ManyToManyField (User , related_name = 'patch_author' , blank = True )
105105 reviewers = models .ManyToManyField (User , related_name = 'patch_reviewer' , blank = True )
106106
107- committer = models .ForeignKey (Committer , blank = True , null = True )
107+ committer = models .ForeignKey (Committer , blank = True , null = True , on_delete = models . CASCADE )
108108
109109 # Users to be notified when something happens
110110 subscribers = models .ManyToManyField (User , related_name = 'patch_subscriber' , blank = True )
@@ -201,8 +201,8 @@ class PatchOnCommitFest(models.Model):
201201 def OPEN_STATUS_CHOICES (cls ):
202202 return [x for x in cls ._STATUS_CHOICES if x [0 ] in cls .OPEN_STATUSES ]
203203
204- patch = models .ForeignKey (Patch , blank = False , null = False )
205- commitfest = models .ForeignKey (CommitFest , blank = False , null = False )
204+ patch = models .ForeignKey (Patch , blank = False , null = False , on_delete = models . CASCADE )
205+ commitfest = models .ForeignKey (CommitFest , blank = False , null = False , on_delete = models . CASCADE )
206206 enterdate = models .DateTimeField (blank = False , null = False )
207207 leavedate = models .DateTimeField (blank = True , null = True )
208208
@@ -222,9 +222,9 @@ class Meta:
222222
223223
224224class PatchHistory (models .Model ):
225- patch = models .ForeignKey (Patch , blank = False , null = False )
225+ patch = models .ForeignKey (Patch , blank = False , null = False , on_delete = models . CASCADE )
226226 date = models .DateTimeField (blank = False , null = False , auto_now_add = True , db_index = True )
227- by = models .ForeignKey (User , blank = False , null = False )
227+ by = models .ForeignKey (User , blank = False , null = False , on_delete = models . CASCADE )
228228 what = models .CharField (max_length = 500 , null = False , blank = False )
229229
230230 @property
@@ -301,7 +301,7 @@ class Meta:
301301
302302
303303class MailThreadAttachment (models .Model ):
304- mailthread = models .ForeignKey (MailThread , null = False , blank = False )
304+ mailthread = models .ForeignKey (MailThread , null = False , blank = False , on_delete = models . CASCADE )
305305 messageid = models .CharField (max_length = 1000 , null = False , blank = False )
306306 attachmentid = models .IntegerField (null = False , blank = False )
307307 filename = models .CharField (max_length = 1000 , null = False , blank = True )
@@ -315,9 +315,9 @@ class Meta:
315315
316316
317317class MailThreadAnnotation (models .Model ):
318- mailthread = models .ForeignKey (MailThread , null = False , blank = False )
318+ mailthread = models .ForeignKey (MailThread , null = False , blank = False , on_delete = models . CASCADE )
319319 date = models .DateTimeField (null = False , blank = False , auto_now_add = True )
320- user = models .ForeignKey (User , null = False , blank = False )
320+ user = models .ForeignKey (User , null = False , blank = False , on_delete = models . CASCADE )
321321 msgid = models .CharField (max_length = 1000 , null = False , blank = False )
322322 annotationtext = models .TextField (null = False , blank = False , max_length = 2000 )
323323 mailsubject = models .CharField (max_length = 500 , null = False , blank = False )
@@ -339,5 +339,5 @@ class PatchStatus(models.Model):
339339
340340
341341class PendingNotification (models .Model ):
342- history = models .ForeignKey (PatchHistory , blank = False , null = False )
343- user = models .ForeignKey (User , blank = False , null = False )
342+ history = models .ForeignKey (PatchHistory , blank = False , null = False , on_delete = models . CASCADE )
343+ user = models .ForeignKey (User , blank = False , null = False , on_delete = models . CASCADE )
0 commit comments