[Answered ]-Django kept previous data in database

1👍

You should use migrations to edit database structure:

https://docs.djangoproject.com/en/1.7/topics/migrations/

Or, if your django version is less than 1.7, South package:

http://south.readthedocs.org/en/latest/

1👍

Just run makemigrations and migrate commands:

python manage.py makemigrations
python manage.py migrate

UPDATE: makemigrations/migrate commands are available since django 1.7.

As @eugene-soldatov mentioned in his answer for django 1.5 you can use the South app.

Another option is to alter the table manually by executing the following SQL query:

echo "ALTER TABLE myapp_photo ADD COLUMN photo_dpi VARCHAR(500) NULL;" | python manage.py dbshell

Where myapp is the name of your application.

Leave a comment