django应用:south的使用

django自学教程:http://www.ziqiangxuetang.com/django/django-views-urls2.html
http://docs.30c.org/djangobook2/chapter10/

环境:python2.7.11 django 1.6 centos6.5 pip8.1.1 mysql 5.1.73 python-mysql1.2.5
安装django数据库管理工具south
pip install south
south的使用http://www.th7.cn/Program/Python/201408/263582.shtml
将juser纳入south管理,执行后,会在对应的juser目录下新建一个migration目录
python manage.py convert_to_south juser
如果 blog 这个 app 之前就创建过相关的表,可以用下面的来“假装”用 South 创建(伪创建,在改动 models.py 之前运行这个,注意如果改动了models.py,需要将其改回原来的再执行。否则相应的变动不会生效)
python manage.py migrate blog –fake
接着,当你对 Blog.models 做任何修改后,只要执行:
python manage.py schemamigration juser –auto
再执行
python manage.py migrate juser 数据表便会同步改变
注意:
假如改动了models.py后又执行了python manage.py convert_to_south juser,生成了migrations的目录,此时再执行python manage.py schemamigration juser –auto不会生效,需要将migrations的目录删除,改回原来的models.py后再convert_to_south

App ‘juser’ converted. Note that South assumed the application’s models matched the database
(i.e. you haven’t changed it since last syncdb); if you have, you should delete the juser/migrations directory, revert models.py so it matches the database, and try again
South对于字段的改名是先删除原来字段,然后添加新的字段。。。对于添加的新字段值会让你填一个默认值。

http://blog.csdn.net/watsy/article/details/11965019
http://www.cnblogs.com/BeginMan/p/3324774.html
http://www.cnblogs.com/BeginMan/p/3325897.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值