Django 路由报错友好提示
2024-10-10 03:34:48
这个方法要在设置路由文件内使用也就是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 才行。
最新文章
- asp.net MVC 应用程序的生命周期
- JSP动作元素——————理论篇
- gulp思考
- linq 日期分组统计
- linux专题一之文件归档和压缩(tar、file、zip)
- java实战之解析xml
- imx6q uboot启动流程牛人的图片(转)
- [转载]提高rails new时bundle install运行速度
- SecureCRT相关
- DeepLearning常用库简要介绍与对比
- mysql添加索引
- Matlab之类型转换
- LSM Tree解析
- 11_Servlet的一些细节知识点
- angularJS 指令一
- android studio 更改快捷键为eclipse中习惯的方式
- HDU 11488 Hyper Prefix Sets (字符串-Trie树)
- 闲扯 Javascript 03 时钟和QQ延时框
- TCP协议中的计时器
- DbGridEh根据某一个字段的值显示对应底色或字体变化
热门文章
- Golang的Json encode/decode以及[]byte和string的转换
- 自定义Attribute类
- lombok 使用 Idea
- 老男孩python学习自修第五天【集合】
- windows 安装tensorflow
- 使用proxychains 代理终端
- .net core 2.0 Unable to convert MySQL date/time to System.DateTime
- BZOJ3291Alice与能源计划——匈牙利算法+模拟费用流
- Codeforces Round #423 Div. 1
- Codeforces Round #507 Div. 1