django的数据管理插件south的使用经验
South is a tool to provide consistent, easy-to-use and database-agnostic migrations for Django applications.
下载地址:http://www.aeracode.org/releases/south/
文档地址:http://south.aeracode.org/docs/index.html
第一次使用:
1 | python manage.py schemamigration youappname --initial |
#以后每次对models更改后,运行以下两条命令同步到数据库
1 | python manage.py schemamigration youappname --auto #检测对models的更改 |
对于一个已存在的项目(定义了models,创建了相应的数据库,保存了响应的数据),这时想要使用South替代原来的syncdb只需要一些简单的步骤:
同样INSTALL_APP里面添加south,然后
1 | python manage.py syncdb #syncdb已经被South更改,用来创建south_migrationhistory表 |
以后在这个项目中就可以正常使用South了