【发布时间】:2017-11-13 07:54:14
【问题描述】:
我有包含所有模板的 dir 模板,并且我有 dir 错误,所有模板都有错误 404.html。 我找到了以下旧解决方案:
在 urls.py 我写的应用程序
from django.conf.urls import (handler400, handler403, handler404, handler500)
handler404 = 'my_app.views.page_not_found'
并在查看我的应用程序
from django.shortcuts import (render_to_response)
from django.template import RequestContext
def page_not_found(request):
response = render_to_response(
'errors/404.html',
context_instance=RequestContext(request))
response.status_code = 404
return response
但我使用的是 Django 1.11,这不起作用。
【问题讨论】: