Skip to content
Advertisement

django foreign key mismatch – “question_question” referencing “question_subject”

Hi there is this problem I have can anyone solve this ?

here is my django model

JavaScript

and here is the error code

JavaScript

and here is the subject model

JavaScript

Advertisement

Answer

This error is likely do to a migration issue. If you are in early development, the quickest solution is to delete migration files and SQLite db, re-run python manage.py makemigrations and python manage.py migrate. Alternatively you can revert all migrations with python manage.py name_of_app migrate -- zero.

See here for more information on reverting migrations.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement