【发布时间】:2020-06-16 16:59:26
【问题描述】:
我是一名学习django开发的学生。 我对 404 和 500 错误有疑问。 我将 404,500 错误分别处理为 404.html 和 500.html。
那么,这两个错误事件有区别吗?
例如,
def example_post_404(request, pk):
get_object_or_404(Post, id=pk) # code that may occur 404 error
vs
def example_post_500(request, pk):
Post.objects.get(id=pk) # code that may occur 500 error
500 错误事件给服务器带来的压力是否比 404 错误事件更大?
哪种代码更受欢迎?
我的代码在 AWS EC2 ubuntu-16.04 上运行
【问题讨论】:
标签: django ubuntu server http-status-code-404