django.db.utils.IntegrityError:

后端 未结 10 679
忘掉有多难
忘掉有多难 2021-01-21 07:47

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

10条回答
  •  情书的邮戳
    2021-01-21 08:05

    You can simply delete all the objects in the main_tutorial table from django shell:

    1. goto command prompt
    2. python manage.py shell
    3. from main.models import Tutorial
    4. Tutorial.objects.all().delete()

    (main being the app name here)

    This will delete all the objects in the Tutorial table and then makemigrations and migrate and it should work just fine.

提交回复
热议问题