【Django】【快捷函数】get_object_or_404
开发环境下的提示

生产环境下的提示

线上生产环境的404报错,是Django默认自带的,也可以自定义一个。如下所示:
代码如下
<!-- templates/404.html -->
<!DOCTYPE html>
<html>
<head>
<title>页面不存在 (404)</title>
<style>
body { font-family: Arial, sans-serif; text-align: center; padding: 50px; }
h1 { color: #d9534f; }
a { color: #337ab7; text-decoration: none; }
</style>
</head>
<body>
<h1>404 - 页面不存在</h1>
<p>您访问的页面已丢失或已被移除。</p>
<p><a href="{% url 'home' %}">返回首页</a></p>
</body>
</html>
前端页面展示效果

这个404的前端页面,放在对应的app的templates下即可
