@@ -60,7 +60,7 @@ class Meta:
60
60
class Author (BaseModel ):
61
61
name = models .CharField (max_length = 50 )
62
62
email = models .EmailField ()
63
- type = models .ForeignKey (AuthorType , null = True )
63
+ type = models .ForeignKey (AuthorType , null = True , on_delete = models . CASCADE )
64
64
65
65
def __str__ (self ):
66
66
return self .name
@@ -71,7 +71,9 @@ class Meta:
71
71
72
72
@python_2_unicode_compatible
73
73
class AuthorBio (BaseModel ):
74
- author = models .OneToOneField (Author , related_name = 'bio' )
74
+ author = models .OneToOneField (
75
+ Author , related_name = 'bio' , on_delete = models .CASCADE
76
+ )
75
77
body = models .TextField ()
76
78
77
79
def __str__ (self ):
@@ -83,7 +85,7 @@ class Meta:
83
85
84
86
@python_2_unicode_compatible
85
87
class Entry (BaseModel ):
86
- blog = models .ForeignKey (Blog )
88
+ blog = models .ForeignKey (Blog , on_delete = models . CASCADE )
87
89
headline = models .CharField (max_length = 255 )
88
90
body_text = models .TextField (null = True )
89
91
pub_date = models .DateField (null = True )
@@ -103,12 +105,15 @@ class Meta:
103
105
104
106
@python_2_unicode_compatible
105
107
class Comment (BaseModel ):
106
- entry = models .ForeignKey (Entry , related_name = 'comments' )
108
+ entry = models .ForeignKey (
109
+ Entry , related_name = 'comments' , on_delete = models .CASCADE
110
+ )
107
111
body = models .TextField ()
108
112
author = models .ForeignKey (
109
113
Author ,
110
114
null = True ,
111
- blank = True
115
+ blank = True ,
116
+ on_delete = models .CASCADE
112
117
)
113
118
114
119
def __str__ (self ):
@@ -133,7 +138,9 @@ class ResearchProject(Project):
133
138
@python_2_unicode_compatible
134
139
class Company (models .Model ):
135
140
name = models .CharField (max_length = 100 )
136
- current_project = models .ForeignKey (Project , related_name = 'companies' )
141
+ current_project = models .ForeignKey (
142
+ Project , related_name = 'companies' , on_delete = models .CASCADE
143
+ )
137
144
future_projects = models .ManyToManyField (Project )
138
145
139
146
def __str__ (self ):
0 commit comments