1、ForeignKey后面未加级联删除
遇到的问题:
File "H:\djangoProject\djangoProject\test\test7\stu\models.py", line 24, in Student cls = models.ForeignKey(Clazz) # 连接班级表 TypeError: __init__() missing 1 required positional argument: 'on_delete'
解决办法:
cls = models.ForeignKey(Clazz, on_delete=models.CASCADE) # 级联删除别忘了加