404页面找不到404页面找不到服务器错误(500)
下面是代码:
在settings.py
DEBUG = False
ALLOWED_HOSTS = ['localhost', '127.0.0.1']
在myapp.views中:
def handle_not_found(request, exception):
return render(request, "404.html")
在项目www.example.com中urls.py:
handler404 = "myapp.views.handle_not_found"
浏览器错误:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/requested_page
Using the URLconf defined in myproject.urls, Django tried these URL patterns, in this order:
URLs shows here...
The current path, requested_page, didn’t match any of these.
1条答案
按热度按时间kpbpu0081#
我得到这个错误是因为我通过404 handers渲染的模板有一个错误。
我已经修复了这个错误,现在它工作得很好。