From 77266b9a0e64f0d23db29421f3553e14f958c460 Mon Sep 17 00:00:00 2001 From: rodzlen Date: Thu, 29 May 2025 17:20:00 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20=EA=B3=B5=EA=B0=84=20?= =?UTF-8?q?=EC=BF=BC=EB=A6=AC=20union=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- search/views/search_views.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/search/views/search_views.py b/search/views/search_views.py index db6ed3c..9054a53 100644 --- a/search/views/search_views.py +++ b/search/views/search_views.py @@ -1,3 +1,5 @@ +from functools import reduce + from django.contrib.gis.db.models.aggregates import Union from django.contrib.gis.measure import D from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator @@ -99,13 +101,11 @@ def get(self, request: HttpRequest) -> JsonResponse: buffered_regions.append(district.geometry.buffer(3000)) if buffered_regions: - # 버퍼 처리된 폴리곤들을 Union - regions_3km = ( - buffered_regions[0].union(*buffered_regions[1:]) - if len(buffered_regions) > 1 - else buffered_regions[0] - ) - qs = qs.filter(location__dwithin=(regions_3km, D(km=0))) + # 버퍼 처리된 폴리곤들을 순차적으로 Union + regions_3km = buffered_regions[0] + for region in buffered_regions[1:]: + regions_3km = regions_3km.union(region) + qs = qs.filter(location__within=regions_3km) # 7. 북마크 여부 if current_user: From b0519a4db71edd1b6a3aeddc218af95ab11a6125 Mon Sep 17 00:00:00 2001 From: rodzlen Date: Thu, 29 May 2025 17:30:16 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=20import=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- search/views/search_views.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/search/views/search_views.py b/search/views/search_views.py index 9054a53..df3e2c5 100644 --- a/search/views/search_views.py +++ b/search/views/search_views.py @@ -1,7 +1,3 @@ -from functools import reduce - -from django.contrib.gis.db.models.aggregates import Union -from django.contrib.gis.measure import D from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator from django.db.models import Q from django.db.models.expressions import Exists, OuterRef