0

IS there is any option to update new field with existing model in django 1.4.I have class name personaldetails having fields "name", "dob", "age" in models.py. Now i want to add new field "location" in the class.how to sync this new field in existing table.

4

2 回答 2

3

你可以使用像这样的插件来实现这一点

于 2013-08-20T11:24:45.847 回答
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

就是这样,你很好

于 2013-08-20T11:52:12.823 回答