Django 路由报错友好提示
这个方法要在设置路由文件内使用也就是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 路由报错友好提示的更多相关文章
- 服务器重启报错:提示fstab readonly报错!( /etc/fstab 只读无法修改的解决办法)
摘自:http://blog.csdn.net/gray13/article/details/7432866 一.问题描述:服务器重启报错:提示fstab readonly报错! 二.问题原因:挂载的 ...
- 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 ...
- Springboot项目启动报错,提示Cannot determine embedded database driver class for database type NONE
我在springboot项目里面引入了数据库的配置: <dependency> <groupId>org.mybatis.spring.boot</groupId> ...
- import cx_Oracle报错,提示importError: DLL load failed: 不是有效的Win32程序。
问题说明1:WIN32,python是2.7版本,本地oracle client是32位的.import cx_Oracle报错,提示importError: DLL load failed: 该模块 ...
- django运行报错TypeError: object supporting the buffer API required
运行django项目报错:TypeError: object supporting the buffer API required 解决方案: 将settings.py中数据库的密码改成字符串格式 源 ...
- YAML_06 playbook从上往下顺序执行,若报错,不提示,继续往下执行
ansible]# vim user4.yml --- - hosts: cache remote_user: root vars: user: bb tasks: - sh ...
- npm install 报错,提示`gyp ERR! stack Error: EACCES: permission denied` 解决方法
m install 报错,提示gyp ERR! stack Error: EACCES: permission denied 猜测可能是因为没有权限读写,ls -la看下文件权限设置情况 [root@ ...
- vue 项目报错,提示:Cannot read property '$createElement' of undefined at render ...
vue 项目报错,提示:Cannot read property '$createElement' of undefined at render ...
- Django独有报错的原因和解决
RuntimeError at /login You called this URL via POST, but the URL doesn't end in a slash and you have ...
随机推荐
- python之路--FTP 上传视频示例
# 服务端 import json import socket import struct server = socket.socket() server.bind(('127.0.0.1',8001 ...
- github & markdown & collapse & table
github & markdown collapse & table https://github.com/Microsoft/TypeScript/issues/30034 GitH ...
- DAY09、函数
一.函数的定义:跟变量名的定义大同小异 1.声明函数的关键词:def 2.函数(变量)名:使用函数的依据 3.参数列表:() 参数个数可以为0到n个,但()一定不能丢,完成功能的必要条件 4.函数 ...
- MySQL中and和or的优先级的问题
参考资料: 关于MySQL中AND和OR的优先级的问题 SQL语句中的AND和OR执行顺序问题 MySQL带OR关键字的多条件查询
- delphi中退出是弹出让你确定的几种确定对话框怎么写?
procedure TForm2.btn1Click(Sender: TObject); begin if MessageBox(Handle, '你确定要退出系统吗?', '信息提示', MB_OK ...
- Ubuntu16.04网络不能访问解决办法
问题: 系统重启后,网络不能正常使用,加载网络配置失败,且重启网络时也提示错误. 解决方法: 在定位的过程中发现是配置中的网络设备号与实际设备号不符. 1.查看网络配置中的配备号: vi /etc ...
- 三、zookeeper安装
一.简介 二.下载解压: #wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.12/zookeeper-3.4.12.tar ...
- bzoj 3626 : [LNOI2014]LCA (树链剖分+线段树)
Description 给出一个n个节点的有根树(编号为0到n-1,根节点为0).一个点的深度定义为这个节点到根的距离+1.设dep[i]表示点i的深度,LCA(i,j)表示i与j的最近公共祖先.有q ...
- HTML head标签内部常用设置
HTML head标签内部常用设置 在网页html文件中,head标签里面通常放置的代码是用来对网页进行相关设置的内容.下面就是对这些内容的介绍. meta标签的设置 在网页中,meta标签最常用的设 ...
- pycharm 2016.1.4 软件注册码生成
昨天电脑忽然坏了,没办法只能电脑重做系统,最让我头疼的是面对新电脑的软件安装和配置..... 由于之前电脑很久没有升级过ide,所以pycharm一直停留在2016.1.4的版本,当我打开pychar ...