django基本过程

1.Django请求生命周期

    URL对应关系(匹配)--试图函数--返回用户字符串

    URL对应关系(匹配)--试图函数--打开一个HTML文件 读取内容显示

return HttpResponse('字符串')

return render(request,'html模板的路径',)

return redirect('跳转的url路径 ')

渲染的模板:

return render(request,'html模板的路径',{字典})????18章17节

配置过程:

setting中 middlerware 注释 csrf  这样就不会输出页面产生问题  

模板路径 DIRS=>[os.path.join(BASE_DIR,'templates'),]

静态文件配置:

settings=》STATICFILES_DIRS=(

     os.path.join(BASE_DIR,'static'),

)

编写过程1:

运行过程1:输出index

1.

 

 2.

 3.

编写过程2:

1.

 2.

 

3.

 

 4.

 

编写过程3:

get  获取数据

post 提交数据  

否则 跳转index首页

原文地址:https://www.cnblogs.com/hmm1995/p/10061003.html