From e37a77fe07bdadb533b795287b08833e233f738e Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 25 Nov 2021 10:47:57 +0530 Subject: [PATCH] Handle range not found --- app/management/commands/import.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/management/commands/import.py b/app/management/commands/import.py index 46ae9ee..fb65000 100644 --- a/app/management/commands/import.py +++ b/app/management/commands/import.py @@ -401,7 +401,10 @@ def handle_object_dict(object_dict, model_name): print('Getting mother_range of %s' % object_dict['mother_range']) if object_dict['mother_range'] == '': object_dict['mother_range'] = 0 - object_dict['mother_range'] = Range.objects.get(id=int(object_dict['mother_range'])) + try: + object_dict['mother_range'] = Range.objects.get(id=int(object_dict['mother_range'])) + except Range.DoesNotExist as dne: + print(str(dne)) if model_name == 'Keyword': object_dict['keyword'] = object_dict['keyword_id'] object_dict.pop('keyword_id')