Print debug only if debug is True

This commit is contained in:
PCoder 2021-11-29 09:32:02 +05:30
parent 34a839422e
commit 20285f20c5

View file

@ -418,7 +418,7 @@ class Command(BaseCommand):
print("Total rows = %s, error rows = %s" % (total, error_row_count))
def handle_object_dict(object_dict, model_name):
def handle_object_dict(object_dict, model_name, debug=False):
if model_name == 'Resource':
object_dict['url'] = object_dict['url'].strip("#")
for i in ['PEGASuS_Check_map_with_author', 'gloria', 'gnomo', 'lter', 'ltser', 'miren', 'team', 'inventory']:
@ -432,11 +432,13 @@ def handle_object_dict(object_dict, model_name):
for f in connected_fields:
for k, v in f.items():
if k in object_dict:
if debug:
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:
if debug:
print('Getting mother_range of %s' % object_dict['mother_range'])
if object_dict['mother_range'] == '':
object_dict['mother_range'] = 0