summaryrefslogtreecommitdiff
path: root/tests/distinct_on_fields
diff options
context:
space:
mode:
authorFlavio Curella <flavio.curella@gmail.com>2015-07-22 09:43:21 -0500
committerTim Graham <timograham@gmail.com>2015-07-27 18:28:13 -0400
commitc2e70f02653519db3a49cd48f5158ccad7434d25 (patch)
treec0f421a6b0c26a7716c380b3e360fecc74d553fb /tests/distinct_on_fields
parent87d55081ea398c65b2503d22ed3907a9175ec729 (diff)
downloaddjango-c2e70f02653519db3a49cd48f5158ccad7434d25.tar.gz
Fixed #21127 -- Started deprecation toward requiring on_delete for ForeignKey/OneToOneField
Diffstat (limited to 'tests/distinct_on_fields')
-rw-r--r--tests/distinct_on_fields/models.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/tests/distinct_on_fields/models.py b/tests/distinct_on_fields/models.py
index 053fd9cc5f..2c33f3ad80 100644
--- a/tests/distinct_on_fields/models.py
+++ b/tests/distinct_on_fields/models.py
@@ -7,8 +7,13 @@ from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Tag(models.Model):
name = models.CharField(max_length=10)
- parent = models.ForeignKey('self', blank=True, null=True,
- related_name='children')
+ parent = models.ForeignKey(
+ 'self',
+ models.SET_NULL,
+ blank=True,
+ null=True,
+ related_name='children',
+ )
class Meta:
ordering = ['name']
@@ -20,14 +25,19 @@ class Tag(models.Model):
@python_2_unicode_compatible
class Celebrity(models.Model):
name = models.CharField("Name", max_length=20)
- greatest_fan = models.ForeignKey("Fan", null=True, unique=True)
+ greatest_fan = models.ForeignKey(
+ "Fan",
+ models.SET_NULL,
+ null=True,
+ unique=True,
+ )
def __str__(self):
return self.name
class Fan(models.Model):
- fan_of = models.ForeignKey(Celebrity)
+ fan_of = models.ForeignKey(Celebrity, models.CASCADE)
@python_2_unicode_compatible
@@ -44,8 +54,8 @@ class Staff(models.Model):
@python_2_unicode_compatible
class StaffTag(models.Model):
- staff = models.ForeignKey(Staff)
- tag = models.ForeignKey(Tag)
+ staff = models.ForeignKey(Staff, models.CASCADE)
+ tag = models.ForeignKey(Tag, models.CASCADE)
def __str__(self):
return "%s -> %s" % (self.tag, self.staff)