Refactor connected_fields import

This commit is contained in:
PCoder 2021-11-29 09:24:17 +05:30
parent d699beadbd
commit 4982b1f936

View file

@ -428,11 +428,13 @@ def handle_object_dict(object_dict, model_name):
# Reinstate range_name key
object_dict['range_name'] = object_dict['range_name_id']
object_dict.pop('range_name_id')
if 'range_name_language' in object_dict:
print('Getting range_name_language of %s' % object_dict['range_name_language'])
if object_dict['range_name_language'] == '':
object_dict['range_name_language'] = 0
object_dict['range_name_language'] = Language.objects.get(id=int(object_dict['range_name_language']))
connected_fields = ['range_name_language', 'feature']
for f in connected_fields:
if f in object_dict:
print('Getting %s of %s' % (f, object_dict[f]))
if object_dict[f] == '':
object_dict[f] = 0
object_dict[f] = Language.objects.get(id=int(object_dict[f]))
if 'mother_range' in object_dict:
print('Getting mother_range of %s' % object_dict['mother_range'])
if object_dict['mother_range'] == '':