Exibindo o erro 404 (página não encontrada) com django.http.Http404 (Not Found)

This commit is contained in:
Luiz Otávio
2023-04-27 11:25:33 -03:00
parent 5f1f4e36ae
commit 44ad292e0b

View File

@@ -1,7 +1,7 @@
from typing import Any from typing import Any
from blog.data import posts from blog.data import posts
from django.http import HttpRequest from django.http import Http404, HttpRequest
from django.shortcuts import render from django.shortcuts import render
@@ -29,7 +29,7 @@ def post(request: HttpRequest, post_id: int):
break break
if found_post is None: if found_post is None:
raise Exception('Post não existe.') raise Http404('Post não existe.')
context = { context = {
# 'text': 'Olá blog', # 'text': 'Olá blog',