In upgrading from Django 2 to 3.2, upon running my server, I suddenly get the following error:
TypeError: on_delete must be callable.
The model field in question is this one:
game_played = models.ForeignKey(Game, "Game Played", help_text="Game Played", null=True, blank=False)
As you can see, on_delete
is not called on this field. Reverting back to Django 2 fixes this issue in that it no longer returns the error. I have tried to add on_delete
to the field, which results in this error:
TypeError: __init__() got multiple values for argument 'on_delete'
I have reviewed the Django 3 docs and cannot find anything related to changes to on_delete
that would affect this. All I can find regarding on_delete
issues are that sometimes people put models.CASCADE
in quotes versus making it callable but that is not the issue here.
How would I fix this issue?
You are supposed to provide the argument for
on_delete
one cannot forego it. Also the second argument for the__init__
ofForeignKey
is not theverbose_name
which you are assuming, instead it ison_delete
, hence you should passverbose_name
as a kwarg if you need to: