Django MySQL error when creating tables

后端 未结 11 1563
感动是毒
感动是毒 2020-12-14 01:02

I am building a django app with a MySQL DB. When I run \'python manage.py migrate\' for the first time, some tables are created well then some errors appear. The error broug

11条回答
  •  臣服心动
    2020-12-14 01:22

    Ran into a similar situation whereby there's

    django.db.utils.OperationalError: (1824, "Failed to open the referenced table 'auth_user'")

    at first, which I resolved by making sure I have all the migrations done properly, every app has its corresponding migrations folder and also __init__.py file within it.

    After which I had the similar issue with another table in the database that raised another error and that's preventing me from starting the test. I solved it by removing all the records in django_migrations table, deleting all the migration files (if you are ok with it). Then I run

    python manage.py makemigrations

    python manage.py migrate --fake

    All the nonsense of the migrations dealt with :)

提交回复
热议问题