前言:django1.8版本出现这种问题,关于标题不好命令,直接看正文问题描述!
问题描述:
在已经生成了models.py中表的情况下,更改了modes.py中的表,但是syncdb不起作用报错。于是我用了个死方法,登录MySQl手动把表删了,也删了应用中migrations文件夹,然后再进行 makemigrations , migrate 和 syncdb,但是去mysql中查看并没有创建相应的表。
后台登录显示: ProgrammingError at /admin/home/article/ (1146, "Table 'alwme_db.home_article' doesn't exist")
(alwme)zhg@hang:~/alwme/alwme$ python manage.py makemigrations home Migrations for 'home': 0001_initial.py: - Create model Article
(alwme)zhg@hang:~/alwme/alwme$ python manage.py migrate Operations to perform: Apply all migrations: admin, home, contenttypes, auth, sessions Running migrations: No migrations to apply.
(alwme)zhg@hang:~/alwme/alwme$ python manage.py syncdb Operations to perform: Apply all migrations: admin, home, contenttypes, auth, sessions Running migrations: No migrations to apply.
解决办法:
在migrations目录中,删除init.py 的文件
比如,是AA app下 那么删除AA下migrations目录中的init.py 的文件,然后再执行python manage.py migrate