
3.打开dows的cmd命令,并切换到此盘下,然后cd进入web文件夹中

4.在web文件夹下开启一个项目:startproject blog

5.开启一个项目后会在web文件夹下的blog文件夹下生成一个manag.py文件,此manage.py所在位置为根目录

6.在manage.py所在目录的blog文件夹下,创建一个hello.py文件。如:

编辑hello.py文件:
#案例1:使用默认http协议7.打开hello.py文件所在目录中的urls文件,进行编辑:
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello django")
#案例2:使用自定义协议
from django.shortcuts import render
def index(request):
ctx={}
ctx["msg"]="python" #将Python存放到request域中,页面通过表达式取值
return
render(request,'hello.html',ctx) #响应

8.找到Python.exe所在的路径 即:C:\Users\Selen\AppData\Local\Programs\Python\Python36-32(ps:找自己电脑上的Python.exe路径)


10.因为在编辑hello.py文件中使用的是http协议,cmd命令中使用的端口是:9999 所以,打开浏览器,地址栏中输入: http://localhost:9999/hello 就完成了!!!!