官术网_书友最值得收藏!

Migrations

Migrations help you to confidently make changes to your models. Introduced in Django 1.7, migrations are essential to a methodical development workflow.

The new workflow is essentially as follows:

  1. The first time you define your model classes, you will need to run the following:
   python manage.py makemigrations <app_label>
  1. This will create migration scripts in the app/migrations folder.
  1. Run the following command in the same (development) environment:
    python manage.py migrate <app_label>
  1. This will apply the model changes to the database. Sometimes, questions are asked to handle the default values, renaming, and so on.
  2. Propagate the migration scripts to other environments. Typically, your version control tool, for example Git, will take care of this. As the latest source is checked out, the new migration scripts will also appear.
  3. Run the following command in these environments to apply the model changes:
    python manage.py migrate <app_label>
  1. Whenever you make changes to the models classes, repeat step 1 to step 5.

If you omit the app_label in the commands, Django will find unapplied changes in every app and migrate them.

主站蜘蛛池模板: 邢台市| 张掖市| 化州市| 五河县| 万州区| 黄大仙区| 明光市| 静安区| 司法| 清苑县| 容城县| 会泽县| 台山市| 新兴县| 治县。| 瓦房店市| 延边| 织金县| 周宁县| 闻喜县| 米脂县| 北海市| 富平县| 富宁县| 胶州市| 互助| 连平县| 鄂托克前旗| 黄山市| 阳高县| 红原县| 盐津县| 九龙城区| 高安市| 铁岭县| SHOW| 潜江市| 广汉市| 凌源市| 茶陵县| 新密市|