What is the best way to migrate data in django

前端 未结 6 1281
渐次进展
渐次进展 2021-01-30 11:27

After making some changes in my models (eg. new field in a model and a new model) what is the best way of reflecting these changes to my populated database?


PS: I

6条回答
  •  长发绾君心
    2021-01-30 11:44

    Perform these steps in order may help you:

    For more details,

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

    1) python manage.py schemamigration apps.appname --initial

    Above step creates migration folder as default.

    2) python manage.py migrate apps.appname --fake

    generates a fake migration.

    3) python manage.py schemamigration apps.appname --auto

    Then you can add fields as you wish and perform the above command.

    4) python manage.py migrate apps.appname

    Then migrate the files to the database.

提交回复
热议问题