From 6fe08cd68901e698f4a0741e177354a45c753b46 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 29 Mar 2011 17:39:59 -0500 Subject: Utilize Django 1.3 'on_delete' feature on several foreign keys The most important one here is PROTECT to keep people from making bone-headed plays and deleting an Arch or Repo and every package along with it. We can use this in a few other places, as well as some carefully placed SET_NULL indicators. Note that nothing here pushes deletion responsibilities down to the database, although that will probably happen in a future commit. Signed-off-by: Dan McGee --- news/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'news') diff --git a/news/models.py b/news/models.py index 5e46751..33d958e 100644 --- a/news/models.py +++ b/news/models.py @@ -6,7 +6,8 @@ from django.contrib.sites.models import Site class News(models.Model): slug = models.SlugField(max_length=255, unique=True) - author = models.ForeignKey(User, related_name='news_author') + author = models.ForeignKey(User, related_name='news_author', + on_delete=models.PROTECT) postdate = models.DateTimeField("post date", db_index=True) last_modified = models.DateTimeField(editable=False, db_index=True) title = models.CharField(max_length=255) -- cgit v1.2.3-24-g4f1b