user
user

Reputation: 695

Django how to migrate new models with existing model

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.

Upvotes: 0

Views: 265

Answers (2)

drabo2005
drabo2005

Reputation: 1096

a very simple way to do it without south migration.

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

and that's it and you good

Upvotes: 1

amdorra
amdorra

Reputation: 1554

you can use a plugin like south to achieve this

Upvotes: 3

Related Questions