Import Keyword properly with correct relation

This commit is contained in:
PCoder 2021-12-01 12:20:17 +05:30
parent 8020fa955e
commit 86536256aa
1 changed files with 6 additions and 0 deletions

View File

@ -457,6 +457,12 @@ def handle_object_dict(object_dict, model_name, debug=False):
if model_name == 'Keyword':
object_dict['keyword'] = object_dict['keyword_id']
object_dict.pop('keyword_id')
if object_dict['keyword'] == '':
object_dict['keyword'] = 0
try:
object_dict['keyword'] = Keyword.objects.get(id=0) # default Keyword which exists already
except Keyword.DoesNotExist as dne:
print(str(dne))
if model_name == 'Organization' and 'country_id' in object_dict:
object_dict['country'] = object_dict['country_id']
object_dict.pop('country_id')