django.db.utils.IntegrityError: The row in table \'main_tutorial\' with primary key \'1\' has an invalid foreign key: main_tutorial.tutorial_series_id contains a
I had this issue a while ago. The above answer maybe correct but it didnt work for me because -im using postgres, i cant just delete the database -migration files were commited in git.
My situation was, I have 004 migration file but i cant run it because of IntegrityError.
I checked the file, and i saw it was in operation list.
The first item of list is migrations.CreateModel and the second was migrations.AddField
here are my steps:
I commented the second item in list, only the CreateModel is remaining.
then run the migrate
open the django admin page and add it manually the missing id
you can add it also in database editor or update statement.
uncomment the AddField section and rerun the migrate.