Refactor connected_fields import
This commit is contained in:
parent
d699beadbd
commit
4982b1f936
1 changed files with 7 additions and 5 deletions
|
@ -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'] == '':
|
||||
|
|
Loading…
Reference in a new issue