AI智能
改变未来

owner = models.ForeignKey(User) TypeError: __init__() missing 1 required positional argument:

python编程从入门到实践
第19章19.3.2将数据关联到用户
models.py原文代码:

owner = models.ForeignKey(User)

执行django shell对话时出现如下错误:
owner = models.ForeignKey(User)
TypeError: init() missing 1 required positional argument: ‘on_delete’

修改如下:

owner = models.ForeignKey(User, on_delete=models.CASCADE)
赞(0) 打赏
未经允许不得转载:爱站程序员基地 » owner = models.ForeignKey(User) TypeError: __init__() missing 1 required positional argument: