Also pass model

This commit is contained in:
PCoder 2021-11-29 09:28:42 +05:30
parent 4982b1f936
commit 34a839422e
1 changed files with 7 additions and 6 deletions

View File

@ -428,13 +428,14 @@ 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')
connected_fields = ['range_name_language', 'feature']
connected_fields = [{'range_name_language': Language}, {'feature': RangeType}]
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]))
for k, v in f.items():
if k in object_dict:
print('Getting %s of %s' % (k, object_dict[k]))
if object_dict[k] == '':
object_dict[k] = 0
object_dict[k] = v.objects.get(id=int(object_dict[k]))
if 'mother_range' in object_dict:
print('Getting mother_range of %s' % object_dict['mother_range'])
if object_dict['mother_range'] == '':