Django : Table doesn't exist

前端 未结 8 1719
再見小時候
再見小時候 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:11

    none of the above solutions worked for me, I finally solved by

    sudo systemctl stop mysql.service
    
    sudo apt-get purge mysql-server
    
    sudo apt-get install mysql-server
    
    sudo systemctl stop mysql.service
    

    In my case the code that I pulled had managed = False and I wanted the tables to be maintained by Django.

    But when I did makemigrations the custom tables were not being detected or I was getting the error that the app_name.Table_name does not exist

    I tried the following:

    1. delete all the migration files inside the migrations folder (except init.py file) and then makemigrations then finally migrate
    2. above 2 answers
    3. this

    PS: This solution is only feasible if backup is present or data is not important or you are just started creating the tables, as purging mysql will lead to loss of data

提交回复
热议问题