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/many_to_one | |
parent | 87d55081ea398c65b2503d22ed3907a9175ec729 (diff) | |
download | django-c2e70f02653519db3a49cd48f5158ccad7434d25.tar.gz |
Fixed #21127 -- Started deprecation toward requiring on_delete for ForeignKey/OneToOneField
Diffstat (limited to 'tests/many_to_one')
-rw-r--r-- | tests/many_to_one/models.py | 20 | ||||
-rw-r--r-- | tests/many_to_one/tests.py | 4 |
2 files changed, 12 insertions, 12 deletions
diff --git a/tests/many_to_one/models.py b/tests/many_to_one/models.py index 6451d9ff2f..57fc7a617b 100644 --- a/tests/many_to_one/models.py +++ b/tests/many_to_one/models.py @@ -23,7 +23,7 @@ class Reporter(models.Model): class Article(models.Model): headline = models.CharField(max_length=100) pub_date = models.DateField() - reporter = models.ForeignKey(Reporter) + reporter = models.ForeignKey(Reporter, models.CASCADE) def __str__(self): return self.headline @@ -40,27 +40,27 @@ class First(models.Model): class Second(models.Model): - first = models.ForeignKey(First, related_name='the_first') + first = models.ForeignKey(First, models.CASCADE, related_name='the_first') # Protect against repetition of #1839, #2415 and #2536. class Third(models.Model): name = models.CharField(max_length=20) - third = models.ForeignKey('self', null=True, related_name='child_set') + third = models.ForeignKey('self', models.SET_NULL, null=True, related_name='child_set') class Parent(models.Model): name = models.CharField(max_length=20, unique=True) - bestchild = models.ForeignKey('Child', null=True, related_name='favored_by') + bestchild = models.ForeignKey('Child', models.SET_NULL, null=True, related_name='favored_by') class Child(models.Model): name = models.CharField(max_length=20) - parent = models.ForeignKey(Parent) + parent = models.ForeignKey(Parent, models.CASCADE) class ToFieldChild(models.Model): - parent = models.ForeignKey(Parent, to_field='name') + parent = models.ForeignKey(Parent, models.CASCADE, to_field='name') # Multiple paths to the same model (#7110, #7125) @@ -73,13 +73,13 @@ class Category(models.Model): class Record(models.Model): - category = models.ForeignKey(Category) + category = models.ForeignKey(Category, models.CASCADE) @python_2_unicode_compatible class Relation(models.Model): - left = models.ForeignKey(Record, related_name='left_set') - right = models.ForeignKey(Record, related_name='right_set') + left = models.ForeignKey(Record, models.CASCADE, related_name='left_set') + right = models.ForeignKey(Record, models.CASCADE, related_name='right_set') def __str__(self): return "%s - %s" % (self.left.category.name, self.right.category.name) @@ -97,4 +97,4 @@ class School(models.Model): class Student(models.Model): - school = models.ForeignKey(School) + school = models.ForeignKey(School, models.CASCADE) diff --git a/tests/many_to_one/tests.py b/tests/many_to_one/tests.py index d828abe8c2..7b2a640b2b 100644 --- a/tests/many_to_one/tests.py +++ b/tests/many_to_one/tests.py @@ -173,7 +173,7 @@ class ManyToOneTests(TestCase): name = models.CharField(max_length=50) class BandMember(models.Model): - band = UnsavedForeignKey(Band) + band = UnsavedForeignKey(Band, models.CASCADE) first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) @@ -609,7 +609,7 @@ class ManyToOneTests(TestCase): def test_fk_instantiation_outside_model(self): # Regression for #12190 -- Should be able to instantiate a FK outside # of a model, and interrogate its related field. - cat = models.ForeignKey(Category) + cat = models.ForeignKey(Category, models.CASCADE) self.assertEqual('id', cat.remote_field.get_related_field().name) def test_relation_unsaved(self): |