mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #30436 -- Added check that on_delete is callable in ForeignKey and OneToOneField.
This commit is contained in:
@@ -21,6 +21,13 @@ class OnDeleteTests(TestCase):
|
||||
a.auto.delete()
|
||||
self.assertFalse(A.objects.filter(name='auto').exists())
|
||||
|
||||
def test_non_callable(self):
|
||||
msg = 'on_delete must be callable.'
|
||||
with self.assertRaisesMessage(TypeError, msg):
|
||||
models.ForeignKey('self', on_delete=None)
|
||||
with self.assertRaisesMessage(TypeError, msg):
|
||||
models.OneToOneField('self', on_delete=None)
|
||||
|
||||
def test_auto_nullable(self):
|
||||
a = create_a('auto_nullable')
|
||||
a.auto_nullable.delete()
|
||||
|
||||
Reference in New Issue
Block a user