Django2.0中编写models类下的ForeignKey
book = models.ForeignKey('BookInfo')
django2.0与之前的1.8不同,
错误:
book = models.ForeignKey('BookInfo')
TypeError: __init__() missing 1 required positional argument: 'on_delete'
解决方法:
book = models.ForeignKey('BookInfo', on_delete=models.CASCADE,)
加上on_delete参数就可以了!!!