django_evolution:不错的django数据库版本插件

邵沛
2023-12-01
django官方自带的manage.py syncdb只能根据已有的models同步新建数据表,而无法做到和rails一样根据实体同步修改数据表,好在有第三方插件可以提供这项功能。
django_evolution
When you run ./manage.py syncdb, Django will look for any new models that have been defined, and add a database table to represent those new models. However, if you make a change to an existing model, ./manage.py syncdb will not make any changes to the database.
This is where Django Evolution fits in. Django Evolution is an extension to Django that allows you to track changes in your models over time, and to update the database to reflect those changes.
使用步骤
1. checkout http://django-evolution.googlecode.com/svn/trunk/ 获取源代码
2. cd django_evolution -> python setup.py install 安装
3. 修改你的django项目的settings.py的INSTALLED_APPS项,比如
INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django_evolution'
)

4.进入你的django项目文件夹, python manage.py syncdb创建 django_evolution所需的表
5.python manage.py evolve --hint --execute 根据实体同步修改你的数据表
over

转载于:https://www.cnblogs.com/yyliuliang/archive/2009/04/30/1447268.html

 类似资料: