Operations to perform: Apply all migrations: admin, contenttypes, sessions, auth Running migrations: No migrations to apply. Your models have changes that are not yet reflected in a migration, and so won't be applied. Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
那么现在需要执行下面的命令
1 2 3 4 5
$ python manage.py makemigrations #得到如下提示 Migrations for 'article': 0001_initial.py: - Create model Article
现在重新运行以下命令
1 2 3 4 5 6
$ python manage.py migrate #出现如下提示表示操作成功 Operations to perform: Apply all migrations: auth, sessions, admin, article, contenttypes Running migrations: Applying article.0001_initial... OK
migrate命令按照app顺序建立或者更新数据库, 将models.py与数据库同步
#Django Shell
现在我们进入Django中的交互式shell来进行数据库的增删改查等操作
1 2 3 4 5 6
$ python manage.py shell Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>>