django 2.X 关联 外键时会报错:TypeError: __init__() missing 1 required positional argument: ‘on_delete’

django 2.X  关联  外键时会报错:TypeError: __init__() missing 1 required positional argument: ‘on_delete’

 #python3 manage.py makemigrations

报错:

解决办法:

contact = models.ForeignKey(Contact, on_delete=models.CASCADE)

加参数:

on_delete=models.CASCADE

One thought on “django 2.X 关联 外键时会报错:TypeError: __init__() missing 1 required positional argument: ‘on_delete’

  1. Guqinz

    Somebody essentially help to make seriously posts I would state. This is the very first time I frequented your website page and thus far? I amazed with the research you made to make this particular publish incredible. Fantastic job!

    Reply

发表评论

电子邮件地址不会被公开。 必填项已用*标注