Added delete triggers to foreign keys

This commit is contained in:
Zakary Timson 2018-05-24 16:11:59 -04:00
parent eaae3c346d
commit b4991f6782
5 changed files with 11 additions and 11 deletions

View File

@ -24,7 +24,7 @@ class Attorney(models.Model):
address = models.CharField(max_length=255) address = models.CharField(max_length=255)
biography = HTMLField(blank=True, null=True) biography = HTMLField(blank=True, null=True)
call_to_bar = models.CharField(max_length=4, blank=True, null=True) call_to_bar = models.CharField(max_length=4, blank=True, null=True)
region = models.ForeignKey(Region, blank=True, null=True) region = models.ForeignKey(Region, blank=True, null=True, on_delete=models.DO_NOTHING)
email = models.CharField(max_length=255) email = models.CharField(max_length=255)
first_name = models.CharField(max_length=100) first_name = models.CharField(max_length=100)
front_page = models.BooleanField(default=False) front_page = models.BooleanField(default=False)
@ -34,9 +34,9 @@ class Attorney(models.Model):
lso = models.CharField(max_length=20, blank= True, null=True) lso = models.CharField(max_length=20, blank= True, null=True)
order = models.IntegerField(blank=True, null=True, verbose_name='Order On Front Page') order = models.IntegerField(blank=True, null=True, verbose_name='Order On Front Page')
phone = models.CharField(max_length=10) phone = models.CharField(max_length=10)
position = models.ForeignKey(Position, blank=True, null=True) position = models.ForeignKey(Position, blank=True, null=True, on_delete=models.DO_NOTHING)
website = models.CharField(max_length=255, blank=True, null=True) website = models.CharField(max_length=255, blank=True, null=True)
user = models.ForeignKey(User, null=True, blank=True) user = models.ForeignKey(User, null=True, blank=True, on_delete=models.DO_NOTHING)
def phone_formatted(self): def phone_formatted(self):
if self.phone is None or self.phone == '': return '' if self.phone is None or self.phone == '': return ''

View File

@ -12,10 +12,10 @@ class Thread(models.Model):
class Post(models.Model): class Post(models.Model):
creator = models.ForeignKey(User) creator = models.ForeignKey(User, on_delete=models.DO_NOTHING)
created = models.DateTimeField(auto_now_add=True) created = models.DateTimeField(auto_now_add=True)
resolved = models.BooleanField(default=False) resolved = models.BooleanField(default=False)
thread = models.ForeignKey(Thread) thread = models.ForeignKey(Thread, on_delete=models.DO_NOTHING)
title = models.CharField(max_length=255) title = models.CharField(max_length=255)
question = HTMLField() question = HTMLField()
@ -24,9 +24,9 @@ class Post(models.Model):
class Comment(models.Model): class Comment(models.Model):
post = models.ForeignKey(Post) post = models.ForeignKey(Post, on_delete=models.DO_NOTHING)
reply = HTMLField() reply = HTMLField()
creator = models.ForeignKey(User) creator = models.ForeignKey(User, on_delete=models.DO_NOTHING)
created = models.DateTimeField(auto_now_add=True) created = models.DateTimeField(auto_now_add=True)
def __str__(self): def __str__(self):

View File

@ -4,4 +4,4 @@ from django.contrib.auth.models import User
class ResetToken(models.Model): class ResetToken(models.Model):
token = models.CharField(max_length=8) token = models.CharField(max_length=8)
user = models.ForeignKey(User) user = models.ForeignKey(User, on_delete=models.DO_NOTHING)

View File

@ -18,11 +18,11 @@ class Attachment(models.Model):
class Newsletter(models.Model): class Newsletter(models.Model):
body = HTMLField() body = HTMLField()
created = models.DateTimeField(auto_now_add=True) created = models.DateTimeField(auto_now_add=True)
creator = models.ForeignKey(User) creator = models.ForeignKey(User, on_delete=models.DO_NOTHING)
publish = models.DateTimeField(default=timezone.now) publish = models.DateTimeField(default=timezone.now)
sent = models.BooleanField(default=False) sent = models.BooleanField(default=False)
subject = models.CharField(max_length=255) subject = models.CharField(max_length=255)
attachments = models.ManyToManyField(Attachment) attachments = models.ManyToManyField(Attachment, blank=True, null=True)
def __str__(self): def __str__(self):
return self.subject return self.subject

View File

@ -15,7 +15,7 @@ class Attachment(models.Model):
class PressRelease(models.Model): class PressRelease(models.Model):
title = models.CharField(max_length=255) title = models.CharField(max_length=255)
created = models.DateTimeField(auto_now_add=True) created = models.DateTimeField(auto_now_add=True)
creator = models.ForeignKey(User) creator = models.ForeignKey(User, on_delete=models.DO_NOTHING)
attachments = models.ManyToManyField(Attachment) attachments = models.ManyToManyField(Attachment)
def __str__(self): def __str__(self):