2013-08-20 43 views
0

有任何选项1.4.I在models.py有田“姓名”,“出生日期”,“年龄”类名personaldetails Django的更新与现有型号的新领域。现在我想在class.how添加新字段“位置”同步在现有表这一新领域。的Django如何将新车型迁移与现有的模型

+0

做你有你的问题的解决方案? – drabo2005

+0

@ abda2005不,你建议dbshel​​l这是手动过程。每次我想改变表格,如果我在模型中做任何改变。您有任何其他的想法 – user

回答

3

你可以使用插件像south实现这一

+0

我使用Django 1.4是否在这个版本南部的作品? – user

+0

是它的工作原理和Django 1.4检查此[链接](http://south.readthedocs.org/en/latest/releasenotes/0.7.4.html)供参考 – amdorra

1

一个非常简单的方法来做到这一点,而不南方迁移。

first add the field name in your model and get under the shell type 

$ python manage.py dbshell 

you will get directly within your database shell (mysql or psql) it up to what database 
you are using. 

mysql> | psql> ALTER TABLE <table_name> ADD column varchar(100); 

and it will add the new column to your table, doesn't matter if the table it already 
    populated or not. 

$ python manage.py syncdb 

,这就是它和你很好的

相关问题