开发者

Displaying Http404 parameter in 404.html template

If I raise a 404 exception in Django using

raise Http404("Error text")

how can I display the Http404 parameter ("Error text" in this case) in my 404.html template?

(I am using the default Django 开发者_StackOverflow社区view to handle 404 errors.)


Check out defining your own 404 Handler. In the view that you write, you can receive the error text and then pass it to the 404 templates.

Keep in mind that based on the HTTP standards, the 404 error is supposed to be for Page Not Found, not a generic error page. Depending on your use case, maybe reevaluate the use of form validation, or other error messages that can inform the user of the problem before the 404 redirect.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜