TypeError: __init__() missing 1 required positional argument: 'on_delete'

在自学Django框架时,在models.py中创建两个数据库表。在第二个表中引用第一个表的id作为外键时,使用了如下语句。

TypeError: __init__() missing 1 required positional argument: 'on_delete'

输入“python manage.py makemigrations"语句后报错,TypeError: __init__() missing 1 required positional argument: 'on_d elete'

根据报错结果进行调试,在关联语句后面加上

“on_delete=models.DO_NOTHING ”即可

TypeError: __init__() missing 1 required positional argument: 'on_delete'

最后在Terminal中依次输入:

 python manage.py makemigrations
 python manage.py migrate

TypeError: __init__() missing 1 required positional argument: 'on_delete'