Django 路由报错友好提示

时间:2021-12-07 22:47:24

这个方法要在设置路由文件内使用也就是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&lowbar;Oracle报错,提示importError&colon; DLL load failed&colon; 不是有效的Win32程序。

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

  5. django运行报错TypeError&colon; object supporting the buffer API required

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

  6. YAML&lowbar;06 playbook从上往下顺序执行,若报错&comma;不提示,继续往下执行

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

  7. npm install 报错,提示&grave;gyp ERR&excl; stack Error&colon; EACCES&colon; permission denied&grave; 解决方法

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

  8. vue 项目报错,提示:Cannot read property &&num;39&semi;&dollar;createElement&&num;39&semi; of undefined at render &period;&period;&period;

    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. UWP控件与DataBind

    在uwp开发中必不可少的一个环节就是各种通用的控件的开发,所以在闲暇时间汇总了一下在uwp开发中控件的几种常用写法,以及属性的几种绑定方式,有可能不全面,请大家多多包涵 :) 1.先从win10新增的 ...

  2. MySQL数据库备份和还原的常用命令小结

    备份MySQL数据库的命令 mysqldump -hhostname -uusername -ppassword databasename > backupfile.sql 备份MySQL数据库 ...

  3. 让git忽略ignore所有文件,只对某些文件进行版本控制

    *.c !frob_*.c !custom.c 或者:*!*/ # 这个的意思是不忽略目录.否则目录被忽略了之后,它里面的所有文件都忽略了!*.c!*.cc!*.cpp!*.cxx 也就是先忽略所有文 ...

  4. poj3257

    dp,先将材料按以终点为关键字升序排 设f[i,j]为过山车到建到位置i在用了j元钱所得到的最大价值,然后 ..] of longint; f:..,..] of longint; l,n,k,m,j ...

  5. 【原】Windows中使用Redis基本入门教程

    Redis是c编写基于Unix平台开发的一种内存KV数据库,官网上并没有给出Window的安装包,但MS基于redis发布了Windows版本. 下载链接: https://github.com/MS ...

  6. Miller&lowbar;Rabin、 Pollard&lowbar;rho Template

    Multiply and pow Function: //计算 (a*b)%c. a,b都是ll的数,直接相乘可能溢出的 // a,b,c <2^63 ll mult_modq(ll a,ll ...

  7. javax&period;el&period;PropertyNotFoundException&colon;Property &&num;39&semi;statisDate&&num;39&semi; not found on type java&period;lang&period;String

    1.错误描述 javax.el.PropertyNotFoundException:Property 'statisDate' not found on type java.lang.String 2 ...

  8. Struts&plus;Hibernate&plus;jsp页面,实现分页

    dao层代码 package com.hanqi.dao; import java.util.ArrayList; import java.util.List; import org.hibernat ...

  9. Python语言&colon;Day11练习题

    24.实现一个整数加法计算器:如:content=input('请输入内容:')#如:5+9或5+ 9或5 + 9 content = input("请输入需要计算的:") #如: ...

  10. Java 基础【15】 压缩与解压缩

    Java.util.zip 提供用于读写标准 ZIP 和 GZIP 文件格式的类. 还包括使用 DEFLATE 压缩算法(用于 ZIP 和 GZIP 文件格式)对数据进行压缩和解压缩的类. 依赖 Jd ...