Django MySQL error when creating tables

后端 未结 11 1572
感动是毒
感动是毒 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:30

    Have you created migrations for all your apps? If not, you may well be hitting the problem that the database tables are being created in the wrong order, which will give you this error.

    If you have an existing Django 1.7 project, then you need to create the initial migration files, and then fake the initial migration, as described here

    https://docs.djangoproject.com/en/1.8/topics/migrations/#adding-migrations-to-apps

    Create the migration with

    $ python manage.py make migrations your_app_label
    

    And then fake the application

    $  python manage.py migrate --fake-initial your_app_label
    

提交回复
热议问题