Django Is telling me table already exists on syncd

2019-07-25 14:37发布

Posted the model at http://pastebin.com/f609771cc

getting error: (yes it's windows) File "C:\Python25\lib\site-packages\MySQLdb\connections.py", line 35, in defaulterrorhandler raise errorclass, errorvalue _mysql_exceptions.OperationalError: (1050, "Table 'memorial_music' already exists")

scanned the whole project directory and memorial_music is only referenced twice

once as a table name and once as table name 'memorial_music_category'

this one has me scratching my head, any ideas?

4条回答
叛逆
2楼-- · 2019-07-25 15:15

django-mptt was the culprit

renamed table for memorial_music to memorial_music_library and everything went smooth

thank you django for manage.py sqlall appname

查看更多
别忘想泡老子
3楼-- · 2019-07-25 15:16

I have the same problem today. Make sure all of your project folders names are lowercase. I think it would all work out.

查看更多
戒情不戒烟
4楼-- · 2019-07-25 15:32

Being a Django newbie I was having syncdb problems all the time. Every time I would run it I would get Error ** table already exists. After searching for answers with no avail and reading over and over again that syncdb : "Creates the database tables for all apps in INSTALLED_APPS whose tables have not already been created.". I finally realized that when I did the initial python manage.py startapp UserData .... the capitalization of UserData was messing Django up (I'm using MYSQL). If would have called it userData I wouldn't have had any problems. I hope this helps someone with the same problem I had.

Edit **

Maybe it wasn't a problem with the capitalization, I think naming a table called userData in Django just doesn't work overall.

查看更多
放我归山
5楼-- · 2019-07-25 15:35

The complaint is that the table already exists in the database. Django cannot update an existing table. You either need to drop the table from the MySQL database, and syncdb again, or manually adjust the table schema to the model.

查看更多
登录 后发表回答