Replace all Range with MountainRange in import script
This commit is contained in:
parent
f828ce5a6e
commit
f1eaedbd14
1 changed files with 6 additions and 6 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue