From 1550e5a3ffe675f86502775599927f3dfc8ced0c Mon Sep 17 00:00:00 2001 From: AlexP077 Date: Sun, 2 Apr 2023 14:53:49 +0300 Subject: [PATCH] fix_csv_upload --- service/utils.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/service/utils.py b/service/utils.py index a85df41..2baaa24 100644 --- a/service/utils.py +++ b/service/utils.py @@ -6,11 +6,9 @@ from geojson import MultiPolygon from tqdm import tqdm from service import models -from service.enums import PointStatus def load_data(filepath: str): - statuses = {point.value: point.name for point in PointStatus} models.PlacementPoint.objects.all().delete() df = pd.read_csv(filepath) df = df.replace(np.nan, None) @@ -18,11 +16,8 @@ def load_data(filepath: str): for row in tqdm(df.to_dict('records'), desc='Loading data...'): data = { k: row[k] for k in row.keys() if - k not in ['id', 'status', 'location_id', 'okrug', 'rayon', 'age_month'] + k not in ['id', 'location_id', 'area', 'district', 'age_month'] } - data['status'] = statuses[row['status']] - data['okrug'] = models.AO.objects.get(name=row['okrug']) - data['rayon'] = models.Rayon.objects.get(name=row['rayon']) models.PlacementPoint.objects.create(**data)