问题描述
根据此处的文档:
表示:
According to the documentation here:https://docs.djangoproject.com/en/1.8/topics/migrations/ it says:
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.
根据我的理解,我首先要做
From what I understand, I first do
makemigrations
创建迁移文件,然后执行
to create the migration file and then do
migrate
要真正应用迁移吗?
请注意,尽管我刚刚开始了Django项目,然后将应用添加到了 installed_apps列表中。之后,我做了
Do note though that I just began my Django project and I added my app to my "installed_apps" list. After that, I did
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的任何事情。
It didn't mention anything about running makemigrations.
推荐答案
根据:
-
python manage.py makemigrations< app>
:创建迁移(生成SQL
命令)。
python manage.py makemigrations <app>
: Create the migrations (generate theSQL
commands).
python manage .py migration
:运行迁移(执行 SQL
命令)。
python manage.py migrate
: Run the migrations (execute the SQL
commands).
这篇关于Django 1.8-迁移和makemigrations有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!