diff --git a/07_Testing-CI-CD/airline0/flights/views.py b/07_Testing-CI-CD/airline0/flights/views.py index 174fd65..6756e76 100644 --- a/07_Testing-CI-CD/airline0/flights/views.py +++ b/07_Testing-CI-CD/airline0/flights/views.py @@ -11,9 +11,12 @@ def index(request): }) def flight(request, flight_id): - flight = Flight.objects.get(pk=flight_id) + try: + flight = Flight.objects.get(pk=flight_id) + except Flight.DoesNotExist: + raise Http404("Flight does not exist") return render(request, "flights/flight.html", { - "flight": flight, + "flight": flight, "passengers": flight.passengers.all(), "non_passengers": Passenger.objects.exclude(flights=flight).all() })