前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >基于Django的电子商务网站开发(连载36)

基于Django的电子商务网站开发(连载36)

作者头像
顾翔
发布2019-12-11 17:24:33
4370
发布2019-12-11 17:24:33
举报

新年加入啄木鸟公众号,好运滚滚來!

顾翔老师开发的bugreport2script开源了,希望大家多提建议。文件在https://github.com/xianggu625/bug2testscript,

主文件是:zentao.py 。bugreport是禅道,script是python3+selenium 3,按照规则在禅道上书写的bugreport可由zentao.py程序生成py测试脚本。

3.8电子支付模块

电子支付模块包括使用支付宝、微信或其他手段进行支付,网上的资料已经很齐全了,读者也可以参阅参考文献【7】。

3.9建立自定义的错误页面

在这里我们主要介绍如何建立自定义的403、404、500错误页面,先建立403.html、404.html和500.html,分别如图3-21、图3-22、图3-23所示。

图3-21 403页面

403页面代码如下。

{%load staticfiles%}<head> <meta charset="UTF-8"> <title>403页面</title> <style type="text/css"> *{ margin: 0; padding: 0; background-color: #FFFFFFF; } div{ width: 700px; height: 200px; background-color: #FFFFFF; } .center-in-center{ position: absolute; top: 40%; left: 30%; } </style></head><body> <div> <img src="{%static 'image/403.JPG'%}" width="228" height="196">你没有这个权限!<br> <a href="/login_action/"><img src="{%static 'image/home.JPG'%}"></a> </div></body></html>

图3-22 404页面

404页面代码如下。

{%load staticfiles%}<head> <meta charset="UTF-8"> <title>404页面</title> <style type="text/css"> *{ margin: 0; padding: 0; background-color: #FFFFFFF; } div{ width: 700px; height: 200px; background-color: #FFFFFF; } .center-in-center{ position: absolute; top: 40%; left: 30%; } </style></head><body> <div> <img src="{%static 'image/404.JPG'%}" width="228" height="196">你的页面找不到了<br> 搜索你想要的或者刷新网页吧! <br> <img src="{%static 'image/reflesh.JPG'%}" onclick="location.reload(); "> </div></body></html>

图3-23 500页面

500页面代码如下。

{%load staticfiles%}<head> <meta charset="UTF-8"> <title>500页面</title> <style type="text/css"> *{ margin: 0; padding: 0; background-color: #FFFFFFF; } div{ width: 700px; height: 200px; background-color: #FFFFFF; } .center-in-center{ position: absolute; top: 40%; left: 30%; } </style></head><body> <div> <img src="{%static 'image/500.JPG'%}" width="228" height="196">服务器内部错误,不能执行这个请求! <br> <a href="/login_action/"><img src="{%static 'image/home.JPG'%}"></a></div></body></html>

然后打开settings.py,配置templates文件路径、关闭Debug、配置allowrd_hosts。

...DEBUG = False # 关闭Debug...TEMPLATES = [ { ... 'DIRS': ['templates/'], # 配置templates文件路径 ... },]...ALLOWED_HOSTS="*"...

最后在views.py中做如下的设置。

...from django.shortcuts import render def page_not_found(request): return render(request, '404.html') def page_error(request): return render(request, '500.html') def permission_denied(request):return render(request, '403.html')...

这样在页面显示403、404和500号错误的时候会显示对应自定义网页。

星云测试

http://www.teststars.cc

奇林软件

http://www.kylinpet.com

联合通测

http://www.quicktesting.net

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2019-02-22,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 软件测试培训 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 3.8电子支付模块
  • 3.9建立自定义的错误页面
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档