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/
4. 访问web

本文档介绍了如何使用Python的pip工具安装Django 3.1.7,并通过django-admin命令创建新的项目。在创建项目后,详细列出了项目的初始文件结构,包括settings.py、urls.py和manage.py。接着演示了启动开发服务器的过程,并提醒用户可能需要运行迁移命令来确保项目正常运行。最后,简要说明了访问web应用的方法。

被折叠的 条评论
为什么被折叠?



