一.settings配置

1.首先需要在settings中将DEBUG由原来的True改为False

DEBUG = False

2.需要设置

ALLOWED_OSTS = ["*"]

二.url设置

三.views中设置

def page_not_found(request,**kwargs):
return render_to_response('404.html')

上面就是配置404的全部过程

四.最后附一个404页面的模板。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>错误页面</title>
<link rel="stylesheet" type="text/css" href="/static/css/404.css"/>
</head> <body style="background:#0186a7;"> <!---404--->
<div class="error_new_bg pr">
<div class="error_new_content">
<div class="error_new pa">
<div class="fl error_new_left"><img src="/static/img/404.png"></div>
<div class="fl error_new_right">
<div class="error_detail">
<p class="error_p_title">哎呦~ 页面没有找到!</p>
<p class="error_p_con">※ 别急,工程师正在紧急处理,马上就好。</p>
<p class="error_p_con">※ 您可联系QQ:1119564976,通知二当家的开发人员!</p>
<p class="error_p_con">※ 感谢您对博客小屋的支持,请您耐心等待!</p>
</div> <p class="error_new_right_btn pr">
<a href="/index" class="type-2 type-3">
<i> 返回首页</i>
<i> 返回首页 </i>
<i> 返回首页 </i>
<i> 返回首页 </i>
</a>
</p>
</div>
</div>
</div>
</div>
</body>
</html>

404.html

html, body {
margin: 0px;
height: 100%;
font-family: "微软雅黑";
} i {
font-style: normal;
} .pr {
position: relative;
} .pa {
position: absolute;
} .fl {
float: left;
} .mb15 {
margin-bottom: 15px;
} .error_new_bg {
height: 100%;
width: 100%;
} .error_new_content {
width: 100%;
height: 100%;
text-align: center;
margin: 0 auto;
background: url(/images/error.png) no-repeat center center;
min-width: 1000px;
} .error_new {
top: 50%;
left: 50%;
margin: -185px 0 0 -500px;
height: 371px;
width: 1000px;
} .error_new_left {
width: 56%;
text-align: right;
-webkit-animation: desc_link ease-in-out 1.5s infinite
} @-webkit-keyframes desc_link {
0% {
-webkit-transform: translateY(0);
-ms-transform: translateY(0);
-0 -transform: translateY(0);
-moz-transform: translateY(0);
transform: translateY(0);
}
50% {
-webkit-transform: translateY(1em);
-ms-transform: translateY(1em);
-0 -transform: translateY(1em);
-moz-transform: translateY(1em);
transform: translateY(1em);
}
100% {
-webkit-transform: translateY(0);
-ms-transform: translateY(0);
-0 -transform: translateY(0);
-moz-transform: translateY(0);
transform: translateY(0);
}
} .error_new_right {
width: 40%;
text-align: left;
margin-top: 7%;
margin-left: 4%;
vertical-align: middle
} .error_new_right_btn {
width: 150px;
height: 46px;
background: #F96900;
display: inline-block;
color: #fff;
line-height: 46px;
border-radius: 3px;
text-align: center;
z-index: 10
} .error_new_right_btn a {
color: #fff;
text-align: center;
font-size: 16px;
width: 150px;
height: 46px;
display: inline-block;
} .error_detail {
margin: 0px;
height: auto;
} .error_detail .error_p_title {
font-size: 28px;
color: #fff;
} .error_detail .error_p_con {
font-size: 14px;
margin-top: 10px;
line-height: 20px;
color: #fff;
} .type-2 {
background: #F96900;
text-indent:;
height: 46px;
width: 150px;
border-radius: 3px;
} .type-3 {
background: #F96900;
text-indent:;
height: 46px;
width: 150px;
border-radius: 3px;
} .type-2 i {
position: absolute;
width: 150px;
height: 46px;
line-height: 46px;
display: block;
top:;
opacity:;
left:;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-transition: all 0.3s linear;
transition: all 0.3s linear;
text-align: center;
color: #ffe8e8;
border-radius: 3px;
} .type-2 i:nth-of-type(2), .type-2 i:nth-of-type(3) {
-webkit-transform: rotateY(-90deg);
transform: rotateY(-90deg);
transform-origin: 0 0;
-webkit-transform-origin: 0 0;
clip: rect(0, 60px, 9999px, 0);
border-shadow: 4px;
} .type-2 i:nth-of-type(3) {
transform-origin: 100% 100%;
-webkit-transform-origin: 100% 100%;
-webkit-transform: rotateY(90deg);
transform: rotateY(90deg);
clip: rect(0, 9999px, 9999px, 60px);
border-shadow: 4px;
} .type-2:hover i:nth-of-type(2), .type-2:hover i:nth-of-type(3) {
-webkit-transform: rotateY(0);
transform: rotateY(0);
background: #fff;
color: #fff;
} .type-2:hover i:first-of-type {
background: #fff;
} .type-2 i:last-of-type {
opacity:;
background: #fff;
color: #ff464b;
-webkit-transition: none;
transition: none;
} .type-3 i:last-of-type {
color: #F96900;
} .type-2:hover i:last-of-type {
opacity:;
-webkit-transition: all 0.05s linear 0.3s;
transition: all 0.05s linear 0.3s;
}

404.css

最后是404.png

Django配置404页面的更多相关文章

  1. 066——VUE中vue-router之rewrite模式下配置404页面

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. shiro+SpringMVC 项目 配置404页面

    说的配置404,大家都会想到去web.xml里面配置 <error-page> <error-code></error-code> <location> ...

  3. IIS配置404页面配置,IIS自定义404页面

    .NET 环境下 用到404页的场景一般有两种: 场景一:报黄页,程序性的错误,代码层可以捕捉到的. 场景二:用户输入不存在的页面,代码层捕捉不到的. IIS 默认会有404的配置,不过这种呈现出的都 ...

  4. 第10篇 WINDOWS2003服务器 IIS上配置404页面的图文教程

    打开IIS 找到你的网站,点右键,选择属性 选择“自定义错误”标签页,找到404的那一项,点“编辑属性”按钮 (方案一)在“消息类型”里选“URL”,然后在下面的“URL”输入框里,填上你的404错误 ...

  5. django 配置404,500页面

    JSP CURL session COOKIE diango 自定义404 500页面     1.首先将settings设置debug=false;             2.设置static路径 ...

  6. 去哪网实习总结:JavaWeb配置404页面(JavaWeb)

    本来是以做数据挖掘的目的进去哪网的,结构却成了系统开发. .. 只是还是比較认真的做了三个月,老师非常认同我的工作态度和成果... 实习立即就要结束了,总结一下几点之前没有注意过的变成习惯和问题.分享 ...

  7. vue配置404页面

    { path:'*', name:"/404", component:cuowu } path星号表示没有这个路由 name表示去这个地址 component这个页面引入的时候叫的 ...

  8. Python django 404页面配置和debug=false 静态文件配置 django版本1.10.5

    django设置404页面 1.设置settings文件 DEBUG = False ALLOWED_HOSTS = ['127.0.0.1', 'localhost']或者 ALLOWED_HOST ...

  9. Spring boot配置404、500页面

    Spring boot 配置404页面很简单,如果你访问的url没有找到就会出现spring boot 提示的页面,很明显Spring boot不用配置就可以显示404页面了. 在template下创 ...

随机推荐

  1. 第39章 引用令牌 - Identity Server 4 中文文档(v1.0.0)

    访问令牌有两种形式 - 自包含或引用. JWT令牌将是一个自包含的访问令牌 - 它是一个带有声明和过期的受保护数据结构.一旦API了解了密钥材料,它就可以验证自包含的令牌,而无需与发行者进行通信.这使 ...

  2. <meta> 标签 和<title> 标签

    <meta> 标签 主流浏览器都支持 <meta> 标签. 标签定义及使用说明 元数据(Metadata)是数据的数据信息. <meta> 标签提供了 HTML 文 ...

  3. 关于mybatis条件查询 报错:元素内容必须由格式正确的字符数据或标记组成

    原查询 select sum(case when age<=16 then 1 else 0 end ) age1, sum(case when age>16 and age<=25 ...

  4. 原生js及H5模拟鼠标点击拖拽

    一.原生js 1.拖拽的流程动作 鼠标按下 触发onmousedown事件 鼠标移动 触发onmousemove事件 鼠标松开 触发onmouseup事件 2.注意事项: 要防止div移出可视框,要限 ...

  5. 基于WanAndroid开放API实现的文章阅读APP

    简介 基于WanAndroid开放API开发的技术文章阅读App.主要功能包括:首页.体系.项目.公众号.搜索.登录.收藏.夜间模式等. 用到的第三方框架 RxJava RxAndroid Retro ...

  6. Error occurred during initialization of VM Could not reserve enough space for 2097152KB object heap

    ionic build Android后的报错问题 ionic 升级了splashscreen和statusbar的插件后,执行ionic build android会一直报打包错误.原因是过低的An ...

  7. WPF:在DataTemplate中使用DataType

    DataTemplate中的DataType的功能实际上和Style中的TargetType很类似. 在Style中,使用了TargetType之后,如果不定义Style的Key,那么这个Style将 ...

  8. C/C++ -- 插入排序算法

    索引: 目录索引 参看代码 GitHub: Sort.cpp 代码简要分析说明: 1.for(int i=1;i<nSize;i++) 这个外层的for循环, [0][1],[1][2],[2] ...

  9. ORA-02030: can only select from fixed tables/views

    有时候给一些普通用户授予查询系统对象(例如dynamic performance views)权限时会遇到"ORA-02030: can only select from fixed tab ...

  10. MR单元测试以及DeBug调试

    Hadoop的MapReduce程序提交到集群环境中运行,出问题时定位非常麻烦,有时需要一遍遍修改代码和打印日志来排查问题,哪怕是比较小的问题.如果数据量很大的话调试起来就相当耗费时间. 而且,Map ...