From ad60692604209ee5d4aa79a05a351e4aa799f292 Mon Sep 17 00:00:00 2001 From: b1ek Date: Wed, 17 May 2023 15:19:47 +1000 Subject: [PATCH] handle empty strings --- pairent_backend/pairent_app/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pairent_backend/pairent_app/views.py b/pairent_backend/pairent_app/views.py index 10a7575..f9d6d11 100644 --- a/pairent_backend/pairent_app/views.py +++ b/pairent_backend/pairent_app/views.py @@ -77,10 +77,10 @@ class ApartmentFilter(viewsets.ViewSet): filtered = []; # TODO: Some better converting practice? - filters['price_range']['from'] = int(filters['price_range']['from']); - filters['price_range']['to'] = int(filters['price_range']['to']); - filters['area_range']['from'] = int(filters['area_range']['from']); - filters['area_range']['to'] = int(filters['area_range']['to']); + filters['price_range']['from'] = int('0' if filters['price_range']['from'] == '' else filters['price_range']['from']); + filters['price_range']['to'] = int('0' if filters['price_range']['to'] == '' else filters['price_range']['to']); + filters['area_range']['from'] = int('0' if filters['area_range']['from'] == '' else filters['area_range']['from']); + filters['area_range']['to'] = int('0' if filters['area_range']['to'] == '' else filters['price_range']['to']); filters['rooms'] = int(filters['rooms']) for entry in unfiltered: