我正在尝试运行我的代码,但收到此错误:
File "C:\Users\JOSHUA\Documents\ypgforum\myproject\boards\models.py", line 13, in <module>
class Topic(models.Model):
File "C:\Users\JOSHUA\Documents\ypgforum\myproject\boards\models.py", line 16, in Topic
board = models.ForeignKey(Board, related_name='topics')
TypeError: __init__() missing 1 required positional argument: 'on_delete'
Run Code Online (Sandbox Code Playgroud)
这是它指向的 models.py:
class Topic(models.Model):
subject = models.CharField(max_length=255)
last_updated = models.DateTimeField(auto_now_add=True)
board = models.ForeignKey(Board, related_name='topics')
starter = models.ForeignKey(User, related_name='topics')
last_updated = models.DateTimeField(auto_now_add=True)
Run Code Online (Sandbox Code Playgroud)