ForeignKey is a Django field for defining a many-to-one relationship.
Up until Django 1.9 the ForeignKey field required a single argument: the model to map to.
Since Django 2.0 the ForeignKey field requires two positional arguments:
the model to map to
the on_delete argument
If without the second argument, error message shows:
File "~/lunch/lunch/stores/models.py", line 16, in MenuItem
store = models.ForeignKey('Store', related_name='menu_items')
TypeError: __init__() missing 1 required positional argument: 'on_delete'
You can find more about on_delete by reading the documentation.
ForeignKey is a Django field for defining a many-to-one relationship.
Up until Django 1.9 the ForeignKey field required a single argument: the model to map to. Since Django 2.0 the ForeignKey field requires two positional arguments:
If without the second argument, error message shows:
You can find more about on_delete by reading the documentation.
Reference: https://www.valentinog.com/blog/django-missing-argument-on-delete/