diff options
author | Flavio Curella <flavio.curella@gmail.com> | 2015-07-22 09:43:21 -0500 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2015-07-27 18:28:13 -0400 |
commit | c2e70f02653519db3a49cd48f5158ccad7434d25 (patch) | |
tree | c0f421a6b0c26a7716c380b3e360fecc74d553fb /tests/distinct_on_fields | |
parent | 87d55081ea398c65b2503d22ed3907a9175ec729 (diff) | |
download | django-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.py | 22 |
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) |