在你改动了 model.py的内容之后执行下面的命令:
python manage.py makemigrations
相当于 在该app下建立 migrations目录,并记录下你所有的关于modes.py的改动,
比如0001_initial.py, 但是这个改动还没有作用到数据库文件
你可以手动打开这个文件,看看里面是什么
在此之后执行命令
python manage.py migrate
将该改动作用到数据库文件,比如产生table之类
node2:/django/mysite#python manage.py migrate
aaaaaaaaaaaaaaaa
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
No migrations to apply.
node2:/django/mysite#cd blog/migrations/
node2:/django/mysite/blog/migrations#ls
node2:/django/mysite/blog/migrations#
node2:/django/mysite#python manage.py makemigrations blog
aaaaaaaaaaaaaaaa
Migrations for 'blog':
blog/migrations/0001_initial.py
- Create model BlogPost
- Create model Book
node2:/django/mysite#python manage.py migrate
aaaaaaaaaaaaaaaa
Operations to perform:
Apply all migrations: admin, auth, blog, contenttypes, sessions
Running migrations:
Applying blog.0001_initial... OK