django.db.utils.IntegrityError:

后端 未结 10 628
忘掉有多难
忘掉有多难 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:02

    The following answer was been posted on the Django tutorial comments of sentdex by nice folks namely: "Kevin di" and "JOSEPH Blessingh". The recommendation helped me and worked like charm:

    There is a file " db.sqlite3 " in your working directory, you can open it with any database management tools that supports SQLite type. following the steps:

    1. For example, " DB Browser for SQLite ", you can Google and download it.
    2. Opening the " db.sqlite3 " file, navigate to the Tables.
    3. Find the main_tutorial table. (Maybe you used another table name in the previous lessons, use your table name.)
    4. Delete record from the table: main_tutorial.
    5. Try python manage.py migrate again.

    The meaning of Delete Record from the table can be explained as: - Click main_tutorial - Then you might see a tab with the name Browse Data - Click it and you will see your records - Press Ctrl + Left Mouse button on the number on the left hand side column to select all the rows - Delete them using right click

提交回复
热议问题