django迁移数据库时报错,TypeError: __init__() missing 1 required positional argument: 'on_delete'

时间:2022-01-02 19:20:53

File "D:\pydj\guest\sign\models.py", line 14, in <module>
class Guest(models.Model):
File "D:\pydj\guest\sign\models.py", line 15, in Guest
event=models.ForeignKey(Event)
TypeError: __init__() missing 1 required positional argument: 'on_delete'

 

将报错行改为

event=models.ForeignKey(Event,on_delete=models.CASCADE)