Skip to content

Commit

Permalink
Add get_object_or_404
Browse files Browse the repository at this point in the history
  • Loading branch information
wsot committed Aug 22, 2022
1 parent 2fc1eac commit 44a9518
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/community_db/views.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)

Expand Down

0 comments on commit 44a9518

Please sign in to comment.