Python学习
Python 学习《Python 编程 从入门到实践》
将数据关联到用户
修改模型Topic时,在models.py 中的Topic中添加字段owner,建立到模型User的外键关系
输入owner = models.ForeignKey(User)后,最后一个括号有填充色,显示: Parameter ‘on_delete’ unfilled
所以用这个关键字去搜了下,下面是原文:
https://blog.****.net/weixin_43458672/article/details/104470368
把on_delete=models.CASCADE写入models.ForeignKey作为参数就可以了。