开发环境
Mac + python3
资料
https://docs.djangoproject.com/en/2.1/
项目初始化
django-admin startproject $project_name
python3 manage.py startapp $app_name
python3 manage.py runserver 0.0.0.0:$port
#1.一个project中包含若干个apps,每个app需要在project的目录下的settings.py中注册
#2.django的默认数据库是自带的
强大的 manage.py
1.manage.py会在新建项目后自动生成
python3 manage.py help
Type 'manage.py help <subcommand>' for help on a specific subcommand.
Available subcommands:
[auth]
changepassword
createsuperuser
[contenttypes]
remove_stale_contenttypes
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
sendtestemail
shell
showmigrations
sqlflush
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
test
testserver
[sessions]
clearsessions
[staticfiles]
collectstatic
findstatic
runserver
利用 manage.py shell 调试api
python3 manage.py shell
网友评论