From f1eaedbd141f73d115cfea236ecfc820164a4351 Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 29 Nov 2021 08:59:07 +0530 Subject: [PATCH] Replace all Range with MountainRange in import script --- app/management/commands/import.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/management/commands/import.py b/app/management/commands/import.py index f77144e..917ff10 100644 --- a/app/management/commands/import.py +++ b/app/management/commands/import.py @@ -384,11 +384,11 @@ class Command(BaseCommand): # We have loaded the range model already and we are attempting to construct the mother_range # relationship try: - this_range = Range.objects.get(id=int(row[0])) - r = Range.objects.get(id=int(row[5])) # default Range which exists already + this_range = MountainRange.objects.get(id=int(row[0])) + r = MountainRange.objects.get(id=int(row[5])) # default Range which exists already this_range.mother_range = r this_range.save() - except Range.DoesNotExist as dne: + except MountainRange.DoesNotExist as dne: print("this range = %s, mother range --> %s" % (row[0], row[5])) print(str(dne)) error_row_count += 1 @@ -416,7 +416,7 @@ def handle_object_dict(object_dict, model_name): for i in ['PEGASuS_Check_map_with_author', 'gloria', 'gnomo', 'lter', 'ltser', 'miren', 'team', 'inventory']: if i in object_dict: object_dict[i] = True if object_dict[i].lower().strip() == 'true' else False - if model_name == 'Range': + if model_name == 'MountainRange': # Reinstate range_name key object_dict['range_name'] = object_dict['range_name_id'] object_dict.pop('range_name_id') @@ -430,8 +430,8 @@ def handle_object_dict(object_dict, model_name): if object_dict['mother_range'] == '': object_dict['mother_range'] = 0 try: - object_dict['mother_range'] = Range.objects.get(id=0) # default Range which exists already - except Range.DoesNotExist as dne: + object_dict['mother_range'] = MountainRange.objects.get(id=0) # default Range which exists already + except MountainRange.DoesNotExist as dne: print(str(dne)) for i in ['checked']: if i in object_dict: