From 44a95182fac7411fd4c4dc4771af34c6ef8f6317 Mon Sep 17 00:00:00 2001 From: Simeon J Morgan Date: Mon, 22 Aug 2022 13:45:54 +1000 Subject: [PATCH] Add get_object_or_404 --- src/community_db/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/community_db/views.py b/src/community_db/views.py index 56ebb50..f63d5dd 100644 --- a/src/community_db/views.py +++ b/src/community_db/views.py @@ -1,5 +1,5 @@ from django.db import models -from django.shortcuts import render +from django.shortcuts import get_object_or_404, render from django.views.generic import DetailView, ListView from .models import Person @@ -21,7 +21,7 @@ def list_persons_with_template(request): def detail_person_with_template(request, pk): - person = Person.objects.get(id=pk) + person = get_object_or_404(Person, id=pk) context = {"object": person} return render(request, "community_db/person_detail_in_base.html", context)