django 访问不到页面时显示404页面

1,修改主目录,settings.py文件

DEBUG = False

ALLOWED_HOSTS = ['*',]

2,在templates目录下放置404.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p>该页面不存在。。。</p>
</body>
</html>

3, 访问不存在页面的时候就会跳转置404.html

Guess you like

Origin blog.csdn.net/qq_26086231/article/details/121061274