Django 1.8-迁移和makemigrations有什么区别? [英] Django 1.8 - what's the difference between migrate and makemigrations?

查看:98
本文介绍了Django 1.8-迁移和makemigrations有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据此处的文档:
https://docs.djangoproject.com/en/ 1.8 / topics / migrations / 表示:

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.

推荐答案

根据投票教程


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

  1. python manage.py makemigrations <app>: Create the migrations (generate the SQL commands).

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

python manage.py migrate: Run the migrations (execute the SQL commands).

这篇关于Django 1.8-迁移和makemigrations有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆