这个方法要在设置路由文件内使用也就是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 才行。

Django 路由报错友好提示的更多相关文章

  1. 服务器重启报错:提示fstab readonly报错!( /etc/fstab 只读无法修改的解决办法)

    摘自:http://blog.csdn.net/gray13/article/details/7432866 一.问题描述:服务器重启报错:提示fstab readonly报错! 二.问题原因:挂载的 ...

  2. python---补充django中文报错(1),Django2.7使用sys.setdefaultencoding('utf-8'),以及使用reload(sys)原因

    SyntaxError at /blog/ news/story Non-ASCII character , but no encoding declared; see http://python.o ...

  3. Springboot项目启动报错,提示Cannot determine embedded database driver class for database type NONE

    我在springboot项目里面引入了数据库的配置: <dependency> <groupId>org.mybatis.spring.boot</groupId> ...

  4. import cx_Oracle报错,提示importError: DLL load failed: 不是有效的Win32程序。

    问题说明1:WIN32,python是2.7版本,本地oracle client是32位的.import cx_Oracle报错,提示importError: DLL load failed: 该模块 ...

  5. django运行报错TypeError: object supporting the buffer API required

    运行django项目报错:TypeError: object supporting the buffer API required 解决方案: 将settings.py中数据库的密码改成字符串格式 源 ...

  6. YAML_06 playbook从上往下顺序执行,若报错,不提示,继续往下执行

    ansible]# vim user4.yml --- - hosts: cache   remote_user: root   vars:     user: bb   tasks:    - sh ...

  7. npm install 报错,提示`gyp ERR! stack Error: EACCES: permission denied` 解决方法

    m install 报错,提示gyp ERR! stack Error: EACCES: permission denied 猜测可能是因为没有权限读写,ls -la看下文件权限设置情况 [root@ ...

  8. vue 项目报错,提示:Cannot read property '$createElement' of undefined at render ...

    vue 项目报错,提示:Cannot read property '$createElement' of undefined at render ...

  9. Django独有报错的原因和解决

    RuntimeError at /login You called this URL via POST, but the URL doesn't end in a slash and you have ...

随机推荐

  1. 在linux命令下访问url

    1.elinks - lynx-like替代角色模式WWW的浏览器 例如: elinks --dump http://www.baidu.com 2.wget 这个会将访问的首页下载到本地 [root ...

  2. Django进阶知识

    drf学习之Django进阶点 一.Django migrations原理 1.makemigrattions: 相当于在每个app下的migrations文件夹下生成一个py脚本文件用于创建表或则修 ...

  3. Fiddler-学习笔记-远程抓包

    1 操作系统低于win7用 fiddler 2 win7 或win7以上版本,用 fiddler4片本 2 fiddler开关:左下角或点击F12控件fiddler开关,开=capturing 3 启 ...

  4. 创建简单的表单Demo

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

  5. has invalid type <class 'numpy.ndarray'>, must be a string or Tensor

    转自: https://blog.csdn.net/jacke121/article/details/78833922 has invalid type <class 'numpy.ndarra ...

  6. hdu 5652(并查集)

    题意:很久之前,在中国和印度之间有通路,通路可以简化为一个n*m的字符串,0表示能通过,1表示障碍,每过一年就有一个坐标变成1,问你什么时候,通路彻底无法通过: 解题思路:无向图的连通性,一般直接搜索 ...

  7. Nginx memcached应用层反向代理

    L:105 Module ngx_http_memcached_module 模块默认编译进Nginx

  8. JarvisOJ Basic Base64?

    GUYDIMZVGQ2DMN3CGRQTONJXGM3TINLGG42DGMZXGM3TINLGGY4DGNBXGYZTGNLGGY3DGNBWMU3WI=== 题目非常具有迷惑性,我一开始以为就是一 ...

  9. js中session操作

    // 保存数据到sessionStorage sessionStorage.setItem('key', 'value');   // 从sessionStorage获取数据 var data = s ...

  10. P1020 导弹拦截

    思路:贪心思路 拿比飞来的导弹高并且高度和飞来的导弹最相近的拦截系统去接, 如果全部都比导弹矮,那就新开一个拦截系统 #include<cstdio> #include<string ...