mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #30436 -- Added check that on_delete is callable in ForeignKey and OneToOneField.
This commit is contained in:
@@ -797,6 +797,8 @@ class ForeignKey(ForeignObject):
|
||||
# the to_field during FK construction. It won't be guaranteed to
|
||||
# be correct until contribute_to_class is called. Refs #12190.
|
||||
to_field = to_field or (to._meta.pk and to._meta.pk.name)
|
||||
if not callable(on_delete):
|
||||
raise TypeError('on_delete must be callable.')
|
||||
|
||||
kwargs['rel'] = self.rel_class(
|
||||
self, to, to_field,
|
||||
|
||||
Reference in New Issue
Block a user