Article From:

Establish a one to many relationship in models of Django2 using ForeignKey ():

1 student = models.ForeignKey("Classes")

Report errors:


1 TypeError: __init__() missing 1 required positional argument: 'on_delete'



1 student = models.ForeignKey("Classes",on_delete=models.CASCADE)

It’s OK with on_delete=models.CASCADE.

Problem analysis:

This is the reason why Django2.0 has been updated over the previous 1.8 editions, and the on_delet parameter must be added to Django2.0.


Leave a Reply

Your email address will not be published. Required fields are marked *