(11_env) localhost:learning_log Leo$
确保在活动的虚拟环境中进行。
(11_env) localhost:learning_log Leo$ python3 manage.py migrate
Operations to perform:
Apply all migrations:admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying sessions.0001_initial... OK
(11_env) localhost:learning_log Leo$
migrate 我们称修改数据库为迁移数据库。首次执行migrate命令, django创建必要的数据库标
(11_env) localhost:learning_log Leo$ ls
11_env db.sqlite3 learning_log manage.py
(11_env) localhost:learning_log Leo$
比之前多了 db.sqlite3 。SQLite 是一种使用单个文件的数据库
查看项目是否正确创建
(11_env) localhost:learning_log Leo$ python3 manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
May 28, 2018 - 09:33:06
Django version 2.0.5, using settings 'learning_log.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
URL 用浏览器打开 http://127.0.0.1:8000/
如果出现“the port is already in use” 意思就是 8000端口被占用
用命令
(11_env) localhost:learning_log Leo$ python3 manage.py runserver 8001
来尝试8001端口