问题详情:
TypeError: init() missing 1 required positional argument: ‘on_delete’
出错地点:
File "E:\08-project\blogproject\blogproject\comments\models.py", line 13, in Comment
post = models.ForeignKey('blog.Post')
TypeError: __init__() missing 1 required positional argument: 'on_delete'
出错原因:
在django2.0后,定义外键和一对一关系的时候需要加on_delete选项,这在1.0+的django版本中是默认参数
参考文章:
https://www.cnblogs.com/phyger/p/8035253.html