Browse files

use on_delete to prevent accidental data deletion

  • Loading branch information...
1 parent cfd758d commit 48cf530317bcba112a7dc8e80b6eb3d3a70e5415 @brosner brosner committed Dec 16, 2011
Showing with 13 additions and 2 deletions.
  1. +13 −2 agora/models.py
View
15 agora/models.py
@@ -52,6 +52,7 @@ class Forum(models.Model):
category = models.ForeignKey(ForumCategory,
null = True,
blank = True,
+ on_delete = models.SET_NULL
)
# @@@ make group-aware
@@ -60,7 +61,12 @@ class Forum(models.Model):
default = datetime.datetime.now,
editable = False
)
- last_reply = models.ForeignKey("ForumReply", null=True, editable=False)
+ last_reply = models.ForeignKey(
+ "ForumReply",
+ null=True,
+ editable=False,
+ on_delete=models.SET_NULL
+ )
view_count = models.IntegerField(default=0, editable=False)
reply_count = models.IntegerField(default=0, editable=False)
@@ -241,7 +247,12 @@ class ForumThread(ForumPost):
default = datetime.datetime.now,
editable = False
)
- last_reply = models.ForeignKey("ForumReply", null=True, editable=False) # only temporarily null
+ last_reply = models.ForeignKey(
+ "ForumReply",
+ null=True,
+ editable=False,
+ on_delete=models.SET_NULL
+ )
# @@@ sticky threads
# @@@ closed threads

0 comments on commit 48cf530

Please sign in to comment.