Skip to content

Commit 3e0dd80

Browse files
committed
Add get_object_or_404
1 parent a6e9a78 commit 3e0dd80

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/community_db/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from django.db import models
2-
from django.shortcuts import render
2+
from django.shortcuts import get_object_or_404, render
33
from django.views.generic import DetailView, ListView
44

55
from .models import Person
@@ -21,7 +21,7 @@ def list_persons_with_template(request):
2121

2222

2323
def detail_person_with_template(request, pk):
24-
person = Person.objects.get(id=pk)
24+
person = get_object_or_404(Person, id=pk)
2525
context = {"object": person}
2626
return render(request, "community_db/person_detail_in_base.html", context)
2727

0 commit comments

Comments
 (0)