gpt4 book ai didi

Django 1.8 - migrate 和 makemigrations 之间有什么区别?

转载 作者:行者123 更新时间:2023-11-28 19:35:36 27 4
gpt4 key购买 nike

根据这里的文档: https://docs.djangoproject.com/en/1.8/topics/migrations/它说:

migrate, which is responsible for applying migrations, as well as unapplying and listing their status.

makemigrations, which is responsible for creating new migrations based on the changes you have made to your models.

据我所知,我先做

makemigrations

创建迁移文件然后执行

migrate

实际应用迁移?

请注意,我刚刚开始我的 Django 项目,并将我的应用程序添加到我的“installed_apps”列表中。之后,我做了

python manage.py runserver

它说

You have unapplied migrations; your app may not work properly until they are applied. Run 'python manage.py migrate' to apply them.

它没有提到任何关于运行 makemigrations 的事情。

最佳答案

根据Polls tutorial :

  1. python manage.py makemigrations <app> : 创建迁移(生成 SQL 命令)。

  2. python manage.py migrate : 运行迁移(执行 SQL 命令)。

关于Django 1.8 - migrate 和 makemigrations 之间有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29980211/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com