Last modified: Jan 10, 2023 By Alexander Williams

How to solve TypeError: __init__() missing 1 required positional argument: 'on_delete' Django

TypeError: __init__() missing 1 required positional argument: 'on_delete' happens when your foreign key field doesn't have on_delete argument.

As you know, from Django 2.0 on_delete is required.

Solve The Issue

To solve this issue, you need to add the on_delete parameter.

For example:


parent = models.ForeignKey(Parent, on_delete=models.CASCADE)

Check the document for more details.

https://docs.djangoproject.com/en/3.2/ref/models/fields/#django.db.models.ForeignKey