这个方法要在设置路由文件内使用也就是urls.py内。

"""mysite URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
#导入整个自定义模块
from . import d2
urlpatterns = [
path('admin/', admin.site.urls),
]
# 统一捕获异常404
#handler400为要捕捉的错误提示这里拿404为例 = 项目名.模块名.方法名
handler404 = "mysite.d2.page_not_found"

因为Django内部设定若果你设置了捕捉错误提示,它就会认为你的项目以经上线,所以必须要在settings.py配置文件内把 DEBUG 改为False 才行。

最新文章

  1. asp.net MVC 应用程序的生命周期
  2. JSP动作元素——————理论篇
  3. gulp思考
  4. linq 日期分组统计
  5. linux专题一之文件归档和压缩(tar、file、zip)
  6. java实战之解析xml
  7. imx6q uboot启动流程牛人的图片(转)
  8. [转载]提高rails new时bundle install运行速度
  9. SecureCRT相关
  10. DeepLearning常用库简要介绍与对比
  11. mysql添加索引
  12. Matlab之类型转换
  13. LSM Tree解析
  14. 11_Servlet的一些细节知识点
  15. angularJS 指令一
  16. android studio 更改快捷键为eclipse中习惯的方式
  17. HDU 11488 Hyper Prefix Sets (字符串-Trie树)
  18. 闲扯 Javascript 03 时钟和QQ延时框
  19. TCP协议中的计时器
  20. DbGridEh根据某一个字段的值显示对应底色或字体变化

热门文章

  1. Golang的Json encode/decode以及[]byte和string的转换
  2. 自定义Attribute类
  3. lombok 使用 Idea
  4. 老男孩python学习自修第五天【集合】
  5. windows 安装tensorflow
  6. 使用proxychains 代理终端
  7. .net core 2.0 Unable to convert MySQL date/time to System.DateTime
  8. BZOJ3291Alice与能源计划——匈牙利算法+模拟费用流
  9. Codeforces Round #423 Div. 1
  10. Codeforces Round #507 Div. 1