Commits

Ed Brannin  committed e96af37

Continuing the tutorial: added a shortcut.'

  • Participants
  • Parent commits 5812958

Comments (0)

Files changed (1)

File baptism_records/baptism/views.py

 # Create your views here.
-from django.shortcuts import render_to_response
+from django.shortcuts import render_to_response, get_object_or_404
 from django.template import Context, loader
 from baptism_records.baptism.models import Christian
 from django.http import HttpResponse
 
 from django.http import Http404
 def detail(request, christian_id):
-    try:
-        c = Christian.objects.get(pk=christian_id)
-    except Christian.DoesNotExist:
-        raise Http404
+    c = get_object_or_404(Christian, pk=christian_id)
     return render_to_response('baptism/detail.html', {'christian': c})