1. 用python的pip工具安装
pip install Django==3.1.7
验证安装成功, 如下命令行
如果能返回如下帮助提示信息,表示安装成功
D:\git>django-admin
Type 'django-admin help <subcommand>' for help on a specific subcommand.
Available subcommands:
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
runserver
sendtestemail
shell
showmigrations
sqlflush
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
test
testserver
2. 创建新项目
以下命令创建好demo project
Sandwich@DESKTOP-VUGTSPF MINGW64 /d/git/django
$ django-admin startproject demo
初始项目的文件
项目配置文件:settings.py
项目路由配置文件:urls.py
项目管理文件: manage.py
3. 启动项目
Sandwich@DESKTOP-VUGTSPF MINGW64 /d/git/django/demo
$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
March 10, 2021 - 01:01:49
Django version 3.1.7, using settings 'demo.settings'
Starting development server at http://127.0.0.1:8000/