I'm trying to migrate my Django project from Python 2.7/Django 1.11 to Python 3.7/Django 2.1.
And I'm a little bit confused with one issue.
Django 2.1 marks as errors all models.ForeignKey(...) code strings in my project with:
TypeError: __init__() missing 1 required positional argument: 'on_delete'
It is because since Django 2.x, 'on_delete' method is required for ForeignKey fields
(Getting TypeError: __init__() missing 1 required positional argument: 'on_delete' when trying to add parent table after child table with entries)
If you'll read this post, solution is pretty simple, you just need to add one of 'on_delete' options, for example:
models.ForeignKey(..., on_delete=models.CASCADE,)
But Django complains not only about actual 'models.py' file but also about all (!) migrations that include "ForeignKey" fields adding or alteration.
So my question is, is it safe to modify old migration files in Django? And is it what I should do in this situation?