Django : Table doesn't exist

前端 未结 8 1703
再見小時候
再見小時候 2020-11-28 07:45

I dropped some table related to an app. and again tried the syncdb command

python manage.py syncdb

It shows error like

dja         


        
8条回答
  •  感情败类
    2020-11-28 08:19

    This is linked to the migration data in the scripts inside the project not matching with the migration scripts in the database as far as I could tell. I solved this by the following steps :

    1. Delete all the migration scripts under migration folder except __ini__
    2. Make sure that the model.py contains the same structure as the table in the database and managed=True
    3. Remove all Django Created tables like auth_user,... etc
    4. Run the following code
    $ ./manage.py makemigrations
    $ ./manage.py migrate
    

    This will create the migration scripts again and will apply it to your database.

提交回复
热议问题