django开发电子商城(十九)django模块的嵌套及登出
2018-01-09 本文已影响43人
天涯笨熊
1:编辑index.html,如果登陆成功,显示登陆成功的用户名,如果没有登陆,显示“你好!请登陆”;并配置上相关链接
![](https://img.haomeiwen.com/i9407607/8e04f8c02c70c7bf.png)
2:编辑views.py,编写登出操作响应函数
![](https://img.haomeiwen.com/i9407607/315ffadffc009e2b.png)
3:在urls.py中,配置logout路由
![](https://img.haomeiwen.com/i9407607/a254ec53b1eea540.png)
4:在tempalte目录下,新建common文件夹,并创建nav_info.html文件,并将头部代码放置到该文件中
![](https://img.haomeiwen.com/i9407607/3985e2677aec203c.png)
5:利用模板语言,在index.htnl中导入nav_info.html
![](https://img.haomeiwen.com/i9407607/7abdb353d81b23ed.png)
6:在其他html中利用index.html的方式,导入nav_info.html