From f7f8d9cb0cee17757c63be4c801388669a96707f Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Sun, 8 Dec 2024 16:34:41 +0100 Subject: [PATCH] On consolide la recherche (erreur 500 des moteurs de recherche) --- src/agenda_culturel/filters.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/agenda_culturel/filters.py b/src/agenda_culturel/filters.py index 07c23e8..a5d9d57 100644 --- a/src/agenda_culturel/filters.py +++ b/src/agenda_culturel/filters.py @@ -137,7 +137,11 @@ class EventFilter(django_filters.FilterSet): if self.get_cleaned_data("position") is None or self.get_cleaned_data("radius") is None: return parent d = self.get_cleaned_data("radius") - p = self.get_cleaned_data("position").location + p = self.get_cleaned_data("position") + if not isinstance(d, str) or not isinstance(p, ReferenceLocation): + return parent + p = p.location + return parent.exclude(exact_location=False).filter(exact_location__location__distance_lt=(p, D(km=d))) def get_url(self): @@ -188,6 +192,7 @@ class EventFilter(django_filters.FilterSet): def get_cleaned_data(self, name): + try: return self.form.cleaned_data[name] except AttributeError: