Pass debug as param
This commit is contained in:
parent
40918e0a70
commit
9871e4ff17
|
@ -291,6 +291,7 @@ class Command(BaseCommand):
|
||||||
parser.add_argument('--app_name', type=str, help="django app name that the model is connected to", default='app')
|
parser.add_argument('--app_name', type=str, help="django app name that the model is connected to", default='app')
|
||||||
parser.add_argument('--mother_range_reload', action='store_true', help="Whether we are trying to reload mother "
|
parser.add_argument('--mother_range_reload', action='store_true', help="Whether we are trying to reload mother "
|
||||||
"range relationship")
|
"range relationship")
|
||||||
|
parser.add_argument('--debug', action='store_true', help="Whether we want to debug")
|
||||||
parser.add_argument('--all', action='store_true', help="Imports all csvs")
|
parser.add_argument('--all', action='store_true', help="Imports all csvs")
|
||||||
|
|
||||||
# ./manage.py import --path /home/pcoder/Downloads/gmbadb/csvs/v2-LU_RedListCategories.csv --model_name RedListCategory --app_name app
|
# ./manage.py import --path /home/pcoder/Downloads/gmbadb/csvs/v2-LU_RedListCategories.csv --model_name RedListCategory --app_name app
|
||||||
|
@ -306,6 +307,7 @@ class Command(BaseCommand):
|
||||||
csv_folder_path = '/home/pcoder/Downloads/gmbadb/csvs'
|
csv_folder_path = '/home/pcoder/Downloads/gmbadb/csvs'
|
||||||
if options['csv_folder_path']:
|
if options['csv_folder_path']:
|
||||||
csv_folder_path = options['csv_folder_path']
|
csv_folder_path = options['csv_folder_path']
|
||||||
|
debug = options.get('debug', None)
|
||||||
if options.get('all'):
|
if options.get('all'):
|
||||||
print("Doing an import of all csvs")
|
print("Doing an import of all csvs")
|
||||||
for csv_file_name, model_name in self.csv_files_models_dict.items():
|
for csv_file_name, model_name in self.csv_files_models_dict.items():
|
||||||
|
@ -399,7 +401,7 @@ class Command(BaseCommand):
|
||||||
error_row_count += 1
|
error_row_count += 1
|
||||||
continue
|
continue
|
||||||
_object_dict = {self.cols_to_django_fields.get(key): value.lstrip('"').rstrip('"') for key, value in zip(header, row)}
|
_object_dict = {self.cols_to_django_fields.get(key): value.lstrip('"').rstrip('"') for key, value in zip(header, row)}
|
||||||
_object_dict = handle_object_dict(_object_dict, model_name)
|
_object_dict = handle_object_dict(_object_dict, model_name, debug=debug)
|
||||||
try:
|
try:
|
||||||
m = _model(**_object_dict)
|
m = _model(**_object_dict)
|
||||||
m.save()
|
m.save()
|
||||||
|
|
Loading…
Reference in New Issue