From 226102ccaf042737b1824003b98c2b26dfa2b83b Mon Sep 17 00:00:00 2001 From: moanos Date: Sun, 27 Apr 2025 15:05:22 +0200 Subject: [PATCH] feat: Display proper 404 when location is not found --- src/fellchensammlung/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fellchensammlung/views.py b/src/fellchensammlung/views.py index 80b85e1..49b531e 100644 --- a/src/fellchensammlung/views.py +++ b/src/fellchensammlung/views.py @@ -3,7 +3,7 @@ import logging from django.contrib.auth.views import redirect_to_login from django.http import HttpResponseRedirect, JsonResponse, HttpResponse from django.http.response import HttpResponseForbidden -from django.shortcuts import render, redirect +from django.shortcuts import render, redirect, get_object_or_404 from django.urls import reverse from django.contrib.auth.decorators import login_required from django.utils import translation @@ -202,7 +202,7 @@ def animal_detail(request, animal_id): def search_important_locations(request, important_location_slug): - i_location = ImportantLocation.objects.get(slug=important_location_slug) + i_location = get_object_or_404(ImportantLocation, slug=important_location_slug) search = Search() search.search_from_predefined_i_location(i_location) context = {"adoption_notices": search.get_adoption_notices(),