Ajout d'un filtre par proximité géographique

This commit is contained in:
Jean-Marie Favreau
2024-10-16 23:55:03 +02:00
parent fba52afbb0
commit 107c55863c
12 changed files with 3682 additions and 252 deletions

3259
src/scripts/communes.json Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,17 @@
import json, os
from django.contrib.gis.geos import Point
from agenda_culturel.models import ReferenceLocation
def run():
input_file = os.path.dirname(__file__) + os.path.sep + "communes.json"
data = []
with open(input_file, 'r') as file:
data = json.load(file)
objs = [ReferenceLocation(location=Point(c["geo_point_2d"]["lon"], c["geo_point_2d"]["lat"]), name=c["com_name"], main="main" in c) for c in data]
objs = ReferenceLocation.objects.bulk_create(objs, ignore_conflicts=True)