From 73e7fe88f85513890ebebce12a2a407037cb8e0b Mon Sep 17 00:00:00 2001 From: Dana Lambert Date: Mon, 8 Nov 2021 10:14:28 +1300 Subject: [PATCH] Fix zone filter if no zone is specified in params --- backend/right_tree/api/filters.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/right_tree/api/filters.py b/backend/right_tree/api/filters.py index 28ad173..f7bf4f4 100644 --- a/backend/right_tree/api/filters.py +++ b/backend/right_tree/api/filters.py @@ -38,8 +38,12 @@ def soil_variant_filter(request, queryset): def zone_filter(request, queryset): zone = request.query_params.get('zone') - zone_json = json.loads(zone) - return queryset.filter(zones__id__contains=zone_json['id']).distinct() + + if zone != None: + zone_json = json.loads(zone) + return queryset.filter(zones__id__contains=zone_json['id']).distinct() + + return queryset def soil_order_coordinate_filter(coordinates):