#安装Django
Pip Install Django #== version number
#选择路径:
D:
#任意文件夹名
CD Django
#罗列Django所提供的命令, where the startproject command to create the project
Django-admin
#新建一个名为guest的项目
Django-admin Startproject Guest
#进入guest
CD Guest
Python manager.py# View the commands provided by manage
Create an App #startapp command
#创建sign应用
Python manage.py Startapp Sign
#运行项目
#python manage.py runserver #可添加地址及端口eg: 127.0.0.1:8000
#访问127.0.0.1:8000
#显示It worked!
#配置guest the/setting.py file to add the sign app to your project
#INSTALLED_APP里添加创建应用, sign
#添加完毕后直接访问127.0.0.1:8000/index, actually page not found
#guest/urls.py Configure access paths,
URL (r ' ^index/$ ', views.index), #urlpatterns里添加
#注意如果urls里面就这么写, actually can not find views, but also need to add the following sentence:
From sign import views
#.. /gign/views.py adding functions
From django.http import HttpResponse
#Create your views here
def index (Request):
Return HttpResponse ("Hello Django")
#但是这样直接访问的是urls里面的方法
#这样, we annotate all the above methods, and write a new
#新建一个index方法
From django.shortcuts Import Render
def index (Request):
return render (Request, "index.html")
#写到这里, not really, because there is not a corresponding index.html to access
#于是我们在sign应用里, create a new templates directory, and Django finds this directory by default
#在templates目录下, create a new index.html
<title>django page</title>
<body>
</body>
Complete a full Django Hello Django workflow at this point;
The Django workflow actually points to sign/views.py from guest/urls.py and executes the request based on the method
Python Django 1.Hello Django