2024-04-19 03:12:52 发布
网友
我有dir模板和所有模板,我有dir错误,所有模板有错误404.html。 我找到了以下老办法:
在网址.py我写的应用程序
from django.conf.urls import (handler400, handler403, handler404, handler500) handler404 = 'my_app.views.page_not_found'
查看我的应用程序
但我使用django1.11,这不起作用。在
如果你遵循docs
您应该返回HttpResponseNotFound,它与HttpResonse相同,只是状态代码不同。它对我有用。在
def bad_request(request): response = render_to_response( 'errors/404.html' ) return HttpResponseNotFound(response.content)
如果你遵循docs
您应该返回HttpResponseNotFound,它与HttpResonse相同,只是状态代码不同。它对我有用。在
相关问题 更多 >
编程相关推荐